博客园  :: 首页  :: 新随笔  :: 订阅 订阅  :: 管理

http://fw.qq.com/ipaddress

Posted on 2011-11-30 13:25  PHP-张工  阅读(4105)  评论(3编辑  收藏  举报

在浏览器中访问:http://fw.qq.com/ipaddress

就可看到你的外网IP 和所在省市

返回内容为:var IPData = new Array("10.85.177.57","","陕西省","西安市");

使用方法

<script src="http://fw.qq.com/ipaddress" charset="gb2312"></script>
<script>
	document.write(IPData[0]); //外网IP
	document.write(IPData[2]); //省
	document.write(IPData[3]); //市
</script>

使用如下连接可获取指定IP的信息

http://www.ip.cn/getip2.php?action=queryip&ip_url=1.85.177.57

返回内容为:您查询的IP是:1.85.177.57 来自:陕西省西安市 电信

 

2013-08-20 更新:

可以使用 http://ip.ws.126.net/ipquery 返回的内容如下:

var lo="陕西省", lc="西安市"; var localAddress={city:"西安市", province:"陕西省"}

使用方法:

<script src="http://ip.ws.126.net/ipquery" charset="gbk"></script>
<script>
    alert(lo + lc);
</script>

 

2014-03-11 更新

淘宝提供的IP查询接口 http://ip.taobao.com/instructions.php

1. 请求接口(GET):

http://ip.taobao.com/service/getIpInfo.php?ip=[ip地址字串]

2. 响应信息:

(json格式的)国家 、省(自治区或直辖市)、市(县)、运营商

3. 返回数据格式:

{"code":0,"data":{"ip":"210.75.225.254","country":"\u4e2d\u56fd","area":"\u534e\u5317",
"region":"\u5317\u4eac\u5e02","city":"\u5317\u4eac\u5e02","county":"","isp":"\u7535\u4fe1",
"country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",
"county_id":"-1","isp_id":"100017"}}
其中code的值的含义为,0:成功,1:失败。