获取用户所在城市

获取用户所在城市

搜狐的方法:

https://pv.sohu.com/cityjson?ie=utf-8
<script src="https://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript">
    var Ip = returnCitySN['cip'];
    var cityname = returnCitySN['cname'];
    localStorage.setItem('Ip', Ip);
    localStorage.setItem('cityname', cityname)
</script>

一定要写https!!!http在正式环境出不来,获取不到值,会被搜狐官方阻止

posted @ 2021-04-12 15:47  圆圆呀~  阅读(183)  评论(0编辑  收藏  举报