Skip to content

Instantly share code, notes, and snippets.

@traverseda
Created January 6, 2017 09:02
Show Gist options
  • Save traverseda/816beee29b5b6561248e18dc06c896b5 to your computer and use it in GitHub Desktop.
Save traverseda/816beee29b5b6561248e18dc06c896b5 to your computer and use it in GitHub Desktop.
A script for finding your real, network-adressable, ip.
from json import loads
import requests
def jsonip():
return loads(requests.get('http://jsonip.com').text)['ip']
def ippl():
return requests.get('http://ip.42.pl/raw').text
def httpbin():
return loads(requests.get('http://httpbin.org/ip').text)['origin']
ipfuncs = [jsonip,ippl,httpbin]
ip = None
for f in ipfuncs:
try:
ip = f()
break
except:
print('failed to get ip with'+str(f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment