Skip to content

@amites /findIP.py
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
find public ip using python (executable)
!#/usr/bin/python
# simple python script to return your public IP address using whatismyip.com
# if executed from command line will display IP
def findIP():
'''
Returns your IP address. Includes setting the header to match the request
see http://www.whatismyip.com/faq/automation.asp
'''
headers = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0)' \
+ ' Gecko/20100101 Firefox/12.0' }
return urllib2.urlopen(
urllib2.Request(
"http://automation.whatismyip.com/n09230945.asp",
None, headers )
).read()
if __name__=="__main__":
print findIP()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.