是否有来自某个大公司的公共API来从程序中获取我的公共IP?
我发现http://ip-address.domaintools.com/myip.xml,这正是我想要的,但不幸的是它阻止了Python urllib以及许多其他的http库,除非你欺骗用户代理(任何做这件事的东西都不能称为API).
问题是我需要这些数据用于一些潜在的开源库,所以我们必须遵守规则.我也知道我可以做类似的事情print $_SERVER[REMOTE_ADDR],但我不想使用我的库为所有人提供流量服务.
那么,是否有类似上面的URL,但真正的API,允许机器人?
Jam*_*ong 95
虽然不是来自大公司,但所有这些都应该有效:
curl icanhazip.com
curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
host -t a dartsclink.com | sed 's/.*has address //'
curl curlmyip.com
curl ifconfig.me # this has a lot of different alternatives too, such as ifconfig.me/host
Run Code Online (Sandbox Code Playgroud)
资源
Ben*_*ing 38
您可以从我的服务http://ipinfo.io获取您的IP和一大堆其他信息:
$ curl ipinfo.io
{
"ip": "67.188.232.131",
"hostname": "c-67-188-232-131.hsd1.ca.comcast.net",
"city": "Mountain View",
"region": "California",
"country": "US",
"loc": "37.385999999999996,-122.0838",
"org": "AS7922 Comcast Cable Communications, Inc.",
"phone": 650
}
Run Code Online (Sandbox Code Playgroud)
如果你只想要IP:
$ curl ipinfo.io/ip
67.188.232.131
Run Code Online (Sandbox Code Playgroud)
这也适用于其他领域,例如:
$ curl ipinfo.io/org
AS7922 Comcast Cable Communications, Inc.
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请访问http://ipinfo.io/developers
| 归档时间: |
|
| 查看次数: |
48253 次 |
| 最近记录: |