API地址:http://int.dpool.sina.com.cn/iplookup/iplookup.php

1
2
3
4
5
6
7
8
function get_location($ip){
 $curl = curl_init();
        curl_setopt($curl,CURLOPT_URL, "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=".$ip);
        $location = curl_exec($curl);
        $location = json_decode($location);
        if($location===FALSE) return "";
        return empty($location->desc) ? $location->province.$location->city.$location->district.$location->isp : $location->desc;
}

update:
2012年又收集到一些ip地址转换的接口,其中发现腾讯的api已经挂了。
腾讯:http://fw.qq.com/ipaddress  (失效打不开)
新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js    (失效打不开)
新浪多地域测试方法:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=12.130.132.30  (失效打不开)
搜狐IP地址查询接口(默认GBK):http://pv.sohu.com/cityjson   (可行)
搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/cityjson?ie=utf-8  (可行)
搜狐另外的IP地址查询接口:http://txt.go.sohu.com/ip/soip
网易有道IP地址API接口:http://www.youdao.com/smartresult-xml/search.s?type=ip&q=115.156.238.114   (失效打不开)

最新文章

  1. YY前端课程5-6
  2. Python科学计算包模块的安装(ubuntu)
  3. android opengl
  4. Unity3D 调用模态对话框/Unity3D MessageBox
  5. CentOS6.5菜鸟之旅:文件权限详解
  6. Unsupervised Classification - Sprawl Classification Algorithm
  7. goLang文件遍历
  8. javascript实现暂停
  9. POJ2187Beauty Contest
  10. python 默认的系统编码 sys.setdefaultencoding
  11. How to Install Tomcat
  12. 算法导论--python--插入排序
  13. C#.NET学习笔记11,12---布尔表达式2组合,if语句
  14. javascript实现的功能--二级联动
  15. mysql 货币字段类型的存储
  16. android UI中添加一张图片如何将这张图片中某一部分设为透明的
  17. CSS禁止用户选择复制
  18. Educational Codeforces Round 63 (Rated for Div. 2) B. Game with Telephone Numbers 博弈思维+模拟+贪心思维
  19. 猜数字游戏,判断输入的数字与系统产生的数字是否一致(Math.random()与if嵌套循环)
  20. Confluence 6 SQL Server 问题解决

热门文章

  1. 基于 OpenResty 实现一个 WS 聊天室
  2. Java程序设计 第16周 课堂实践 —— 数据库4
  3. 201552-53 《Java程序设计》第五周问题汇总
  4. 20155222 2016-2017-2 《Java程序设计》实验三
  5. 20155301 2016-2017-2 《Java程序设计》第8周学习总结
  6. 20155302 2016-2017-2 《Java程序设计》第十周学习总结
  7. SSM框架及例子(转)
  8. SQLite3日期与时间,常见函数
  9. mac php版本切换
  10. JS 中屏幕、浏览器和文档的高度、宽度和距离