Create a gist now

Instantly share code, notes, and snippets.

find public ip using python (executable)
# simple python script to return your public IP address using
# if executed from command line will display IP
def findIP():
Returns your IP address. Includes setting the header to match the request
headers = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0)' \
+ ' Gecko/20100101 Firefox/12.0' }
return urllib2.urlopen(
None, headers )
if __name__=="__main__":
print findIP()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment