关于js(外部接口获取ip的方法.城市)
小白
2019-10-10
【jquery】
新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js
(默认为纯文本格式,根据format的参数定义,还可以返回JS、Json格式)。
新浪多地域测试方法:
http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=219.242.98.111
搜狐IP地址查询接口(默认GBK):http://pv.sohu.com/cityjson
搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/cityjson?ie=utf-8
使用方法:利用搜狐查询接口举例说明
简单粗暴.很直接,适合微信公众号及html5等移动页面
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script> <script type="text/javascript"> console.log(returnCitySN["cip"]+','+returnCitySN["cname"]) </script>