Python Forum

Full Version: urls to get ip
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
since i have been working on a module/command to get the user's current public IP address, as the world sees it, and web queries seem to be the way to go, i have done some searching and found several with easy output (mostly JSON or a raw IP) and decided to share my list.

connected  to 'https://api.ipify.org?format=json'
response = '{"ip":"10.20.30.40"}'
connected  to 'http://jsonip.com/'
response = '{"ip":"10.20.30.40","about":"/about","Pro!":"http://getjsonip.com"}'
connected  to 'http://icanhazip.com'
response = '10.20.30.40\n'
connected  to 'http://ipinfo.io/ip'
response = '10.20.30.40\n'
connected  to 'http://whatismyip.akamai.com/'
response = '10.20.30.40'
connected  to 'http://checkip.dyndns.org/'
response = '<html><head><title>Current IP Check</title></head><body>Current IP Address: 10.20.30.40</body></html>\r\n'
connected  to 'http://ipinfo.io/json'
response = '{\n  "ip": "10.20.30.40",\n  "hostname": "host.name",\n  "city": "",\n  "region": "",\n  "country": "XX",\n  "loc": "lat,long'\
connected  to 'https://ipinfo.io/json'
response = '{\n  "ip": "10.20.30.40",\n  "hostname": "host.name",\n  "city": "",\n  "region": "",\n  "country": "XX",\n  "loc": "lat,long'\
connected  to 'https://ifconfig.co/json'
response = '{"ip":"10.20.30.40","ip_decimal":169090600,"country":"Countyname","city":"Unknown","hostname":"host.name"}'
connected  to 'https://api.ipify.org?format=json'
response = '{"ip":"10.20.30.40"}'
edit 1: show each response format like a python string literal assignment
thanks! i have some more, now.  but a couple of those don't work.  checkip.amazonaws.com has a bad TLS key (wrong hostname reference) and once you get around that, it redirects to a login page. telize.com is down and the main page has a link to a page that explains why.
I didn't check them since I wrote the script to see my public address. It uses icanhazip.com and it works all the time.
it would have been useful if translate/NAT standards had an ICMP request which required each point where the address changes to add the new address and TTL to a list in the payload and send it back as a reply when the TTL runs out.
(Dec-31-2016, 03:31 AM)Skaperen Wrote: [ -> ]it would have been useful if translate/NAT standards had an ICMP request which required each point where the address changes to add the new address and TTL to a list in the payload and send it back as a reply when the TTL runs out.

Useful to hackers mostly...
i suppose so.
Some fun with it,a more fancy version of "what's my ip" that all need Liar
To run what_ip
git clone https://[email protected]/snippsat/what_ip.git
# Now cd into what_ip folder
python app.py
# In browser
http://127.0.0.1:5000/
(Jan-02-2017, 04:03 AM)snippsat Wrote: [ -> ]Some fun with it,a more fancy version of "what's my ip" that all need Liar
To run what_ip

is that the server code?  i just found the one i made in C many years ago that used a library i wrote that simplified writing daemons (maybe as much as could be done in C).  ask me for "httpaddrhtml.c" and/or "httpaddrjson.c" if you want to see the source.
Quote:is that the server code?
Yes,if you new to Flask running python app.py start the build in Flask web-server.
The severer is running,then in browser http://127.0.0.1:5000/.
Need Flask and Requests pip install Flask requests
Quote: i just found the one i made in C many years ago that used a library i wrote that simplified writing daemons (maybe as much as could be done in C)
Cool Cool 
but i think a web-app is the more modern approach.
Pages: 1 2 3