天天看點

轉載:騰訊與新浪的通過IP位址擷取目前地理位置(省份)的接口

騰訊的接口是 ,傳回數組 http://fw.qq.com/ipaddress 

傳回值 var IPData = new Array("61.135.152.194","","北京市",""); 

新浪的接口 : 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 

傳回值 var remote_ip_info = {"ret":1,"start":"218.192.0.0","end":"218.192.7.255","country":"\u4e2d\u56fd","province":"\u5e7f\u4e1c","city":"\u5e7f\u5dde","district":"","isp":"\u6559\u80b2\u7f51","type":"\u5b66\u6821","desc":"\u5e7f\u5dde\u5927\u5b66\u7eba\u7ec7\u670d\u88c5\u5b66\u9662"}; 

通過jquery 擷取相應的資料

$.getScript('資料接口',function(){ 
//騰訊:IPData[0]  
 //新浪:remote_ip_info.country 
... 
})       

js直接調用城市資料

document.write(remote_ip_info.city);      

簡單的使用方法(新浪接口)

<!-- 引入接口 -->
<script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>

<!-- 簡單調用城市資料-->
      
<script>document.write(remote_ip_info.city);</script>      

 搜狐接口,擷取IP、城市、和用戶端辨別(MAC位址?)

<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>  
<script type="text/javascript">  
  document.write(returnCitySN["cip"]+','+returnCitySN["cname"])  
</script>      

摘自:http://www.jb51.net/article/24370.htm

轉載于:https://www.cnblogs.com/MY0101/p/7902730.html