Skip to content

Instantly share code, notes, and snippets.

@bussiere
Created August 13, 2010 13:26
Show Gist options
  • Save bussiere/522875 to your computer and use it in GitHub Desktop.
Save bussiere/522875 to your computer and use it in GitHub Desktop.
#Show internet IP
import socket
import urllib2
import re
def get_local():
data = ""
data += str(socket.gethostbyname(socket.gethostname()))
return data
def get_internet():
the_url = 'http://www.showmyip.com'
try :
req = urllib2.Request(the_url)
handle = urllib2.urlopen(req)
the_page = handle.read()
exp = re.compile("""Internet.*.-->""")
the_page = exp.findall(the_page)
the_page = the_page[0][9:]
the_page = the_page.replace(' -->','')
except :
the_page = ""
return str(the_page)
print get_local()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment