Created
August 13, 2010 13:26
-
-
Save bussiere/522875 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#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