Created
January 6, 2017 09:02
-
-
Save traverseda/816beee29b5b6561248e18dc06c896b5 to your computer and use it in GitHub Desktop.
A script for finding your real, network-adressable, ip.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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