有没有大公司的公有API可以在程序中获取我的公网ip?
我已经找到了http://ip-address.domaintools.com/myip.xml
,这正是我想要的,但不幸的是,它阻塞了Python和许多其他的http库,除非你欺骗用户代理(任何这样做的东西都不能被称为urllib
)。
问题是,我需要为一些潜在的开源库提供这些数据,所以我们必须遵守规则。我也知道我可以像print $_SERVER[REMOTE_ADDR]
一样做smth,但我不想让每个使用我的库的人都有流量。
那么,有没有像上面的URL一样的东西,但真正的API,允许机器人?
发布于 2010-06-23 06:32:43
虽然不是来自大公司,但所有这些都应该有效:
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
来源
发布于 2013-10-31 13:13:43
您可以从我的服务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
}
如果您只想要IP:
$ curl ipinfo.io/ip
67.188.232.131
这也适用于其他字段,例如:
$ curl ipinfo.io/org
AS7922 Comcast Cable Communications, Inc.
有关更多详细信息,请访问http://ipinfo.io/developers
发布于 2013-11-09 22:01:41
https://stackoverflow.com/questions/3097589
复制相似问题