Getting my public IP via API [closed]

2019-01-10 04:44发布

Is there a public API from some big company to get my public ip from within a program?

I've found http://ip-address.domaintools.com/myip.xml, which is exactly what I want, but unfortunately it blocks Python's urllib as well as many other http libraries, unless you spoof user-agent (anything doing that can't be called an API at all).

The problem is that I need this data for some potentially open source library, so we have to play by the rules. I also know that I can just do smth like print $_SERVER[REMOTE_ADDR], but I don't want to server traffic to everyone using my library.

So, is there something like the URL above, but real API, that allows robots?

标签: api ip
8条回答
疯言疯语
2楼-- · 2019-01-10 05:09

you can use web service API's which do this work like:

see example of service: http://ip-api.com and usage: http://whatmyip.info

good luck!!!

查看更多
登录 后发表回答