Python - My External IP Address
1 2 import urllib 3 4 url = urllib.URLopener() 5 resp = url.open('http://myip.dk') 6 html = resp.read(114) 7 8 end = html.find("</title>") 9 start = html.find("IP:") + 3 10 11 print html[start:end].strip()
DZone Snippets > whitetiger > address
12730 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
1 2 import urllib 3 4 url = urllib.URLopener() 5 resp = url.open('http://myip.dk') 6 html = resp.read(114) 7 8 end = html.find("</title>") 9 start = html.find("IP:") + 3 10 11 print html[start:end].strip()