免费接口如下:
新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js
新浪多地域测试方法:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=218.192.3.42
搜狐IP地址查询接口(默认GBK):http://pv.sohu.com/cityjson
搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/cityjson?ie=utf-8
搜狐另外的IP地址查询接口:http://txt.go.sohu.com/ip/soip
以新浪为例,调用jQuery的getScript()$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function() { $("#depcity").val(getCity(remote_ip_info.city)); });新浪的ip地址查询接口返回值为:
var remote_ip_info = {"ret":1,"start":-1,"end":-1,"country":"u4e2du56fd","province":"u6c5fu82cf","city":"u5f90u5dde","district":"","isp":"","type":"","desc":""};
百度免费接口:
http://api.map.baidu.com/location/ip?ak=F454f8a5efe5e577997931cc01de3974&ip=180.124.234.248ak:密钥
ip:ip地址
响应结果:
{ "address":"CN|江苏|徐州|None|CHINANET|0|0", "content":{ "address_detail":{ "province":"江苏省", "city":"徐州市", "district":"", "street":"", "street_number":"", "city_code":316 }, "address":"江苏省徐州市", "point":{ "y":"4041039.6", "x":"13045462.3" } }, "status":0 }