当前位置: 首页 > 工具软件 > ip-location > 使用案例 >

第三方接口获取IP归属地

长孙硕
2023-12-01

如何获取IP请参照我的另外一篇博文:PHP获取客户端IP常用方法及安全隐患

 下面我整理了几个目前免费可用的IP归属地接口:

 1、淘宝:http://ip.taobao.com/service/getIpInfo.php?ip=
 

示例:http://ip.taobao.com/service/getIpInfo2.php?ip=120.36.254.31

{"code":0,"data":{"ip":"120.36.254.31","country":"中国","area":"","region":"福建","city":"厦门","county":"XX","isp":"电信","country_id":"CN","area_id":"","region_id":"350000","city_id":"350200","county_id":"xx","isp_id":"100017"}}

 

2、pconlinehttp://whois.pconline.com.cn/ip.jsp?ip=(支持多种格式返回,请参照:http://whois.pconline.com.cn

示例:http://whois.pconline.com.cn/ip.jsp?ip=120.41.245.48

福建省厦门市 电信

 

3、126:http://ip.ws.126.net/ipquery?ip=

示例:http://ip.ws.126.net/ipquery?ip=120.36.254.31

var lo="福建省", lc="厦门市"; var localAddress={city:"厦门市", province:"福建省"}  

 

4、百度:http://api.map.baidu.com/location/ip?ak=F454f8a5efe5e577997931cc01de3974&ip=

示例:http://api.map.baidu.com/location/ip?ak=F454f8a5efe5e577997931cc01de3974&ip=120.36.254.31

{
    "address": "CN|福建|厦门|None|CHINANET|0|0",
    "content": {
        "address_detail": {
            "province": "福建省",
            "city": "厦门市",
            "district": "",
            "street": "",
            "street_number": "",
            "city_code": 194
        },
        "address": "福建省厦门市",
        "point": {
            "y": "2795265.28",
            "x": "13147407.51"
        }
    },
    "status": 0
}

 

5、搜狐:http://pv.sohu.com/cityjson(默认GBK编码,修改编码加参数 ?ie=utf-8

示例:http://pv.sohu.com/cityjson

var returnCitySN = {"cip": "120.36.254.31", "cid": "350200", "cname": "福建省厦门市"};

 

 

 

 类似资料: