在线IP到地理位置解析的API接口

有的时候,我们有IP到地理位置解析的需求。如下是本人在日常科研中遇到的开源可用api.

1. ip-api:

方法:
url: http://ip-api.com/batch
方法:POST
Header:

Content-Type:application/json
Host: ip-api.com
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/3.2.0

Post Data:

[{"query":"37.120.210.178","lang":"zh"},{"query":"5.181.235.14","lang":"zh"},{"query":"91.207.174.26","lang":"zh"},{"query":"37.120.154.37","lang":"zh"},{"query":"5.181.235.142","lang":"zh"}]

响应:

[
    {
        "status": "success",
        "country": "Japan",
        "countryCode": "JP",
        "region": "13",
        "regionName": "Tokyo",
        "city": "Higashishinagawa",
        "zip": "140-0002",
        "lat": 35.6191,
        "lon": 139.751,
        "timezone": "Asia/Tokyo",
        "isp": "M247",
        "org": "M247 Ltd",
        "as": "AS9009 M247",
        "query": "37.120.210.178"
    },
    {
        "status": "success",
        "country": "Japan",
        "countryCode": "JP",
        "region": "13",
        "regionName": "Tokyo",
        "city": "Higashishinagawa",
        "zip": "140-0002",
        "lat": 35.6191,
        "lon": 139.751,
        "timezone": "Asia/Tokyo",
        "isp": "M247",
        "org": "M247 LTD",
        "as": "AS9009 M247",
        "query": "5.181.235.14"
    },
    {
        "status": "success",
        "country": "Japan",
        "countryCode": "JP",
        "region": "23",
        "regionName": "Aichi",
        "city": "Nagoya",
        "zip": "461-0019",
        "lat": 35.1815,
        "lon": 136.906,
        "timezone": "Asia/Tokyo",
        "isp": "M247",
        "org": "M247 Ltd",
        "as": "AS9009 M247",
        "query": "91.207.174.26"
    },
    {
        "status": "success",
        "country": "Japan",
        "countryCode": "JP",
        "region": "13",
        "regionName": "Tokyo",
        "city": "Higashishinagawa",
        "zip": "140-0002",
        "lat": 35.6191,
        "lon": 139.751,
        "timezone": "Asia/Tokyo",
        "isp": "M247",
        "org": "M247 Ltd",
        "as": "AS9009 M247",
        "query": "37.120.154.37"
    },
    {
        "status": "success",
        "country": "Japan",
        "countryCode": "JP",
        "region": "13",
        "regionName": "Tokyo",
        "city": "Higashishinagawa",
        "zip": "140-0002",
        "lat": 35.6191,
        "lon": 139.751,
        "timezone": "Asia/Tokyo",
        "isp": "M247",
        "org": "M247 LTD",
        "as": "AS9009 M247",
        "query": "5.181.235.142"
    }
]

响应有AS号,有时区,经纬度,还有组织名。

2. ipinfo官网的接口

https://ipinfo.io/ 给的IP属性信息可以说是相当的详细了。

接口文档:https://github.com/ipinfo/python

这个接口需要使用用户名和token,每个token每个月有5w次免费查询。可喜的是,我们可以使用一些免费邮箱(比如protonmail.com)注册大量的用户来薅羊毛,50个用户就有250w次免费查询了,这个量还是可以的。

例子:
这可以说是相当的详细了。

{'abuse': {'address': 'US, CA, Mountain View, 1600 Amphitheatre Parkway, 94043',
           'country': 'US',
           'email': '[email protected]',
           'name': 'Abuse',
           'network': '216.239.32.0/19',
           'phone': '+1-650-253-0000'},
 'asn': {'asn': 'AS15169',
         'domain': 'google.com',
         'name': 'Google LLC',
         'route': '216.239.36.0/24',
         'type': 'business'},
 'city': 'Mountain View',
 'company': {'domain': 'google.com', 'name': 'Google LLC', 'type': 'business'},
 'country': 'US',
 'country_name': 'United States',
 'hosting': {'host': 'google',
             'id': 'GOOGLE',
             'name': 'Google LLC',
             'network': '216.239.32.0/19'},
 'hostname': 'any-in-2415.1e100.net',
 'ip': '216.239.36.21',
 'latitude': '37.3861',
 'loc': '37.3861,-122.0840',
 'longitude': '-122.0840',
 'postal': '94035',
 'region': 'California',
 'timezone': 'America/Los_Angeles'}

分享一个可用的token:

token info
009f38eca7a93e protonmail.com
发布了307 篇原创文章 · 获赞 268 · 访问量 56万+

猜你喜欢

转载自blog.csdn.net/jmh1996/article/details/104264341
今日推荐