Over a million developers have joined DZone.

Python - My External IP Address

Build APIs from SQL and NoSQL data sources in seconds. Read the Creating REST APIs white paper, brought to you in partnership with CA Technologies.

import urllib

url = urllib.URLopener()
resp = url.open('http://myip.dk')
html = resp.read(114)

end = html.find("</title>")
start = html.find("IP:") + 3

print html[start:end].strip()


The Integration Zone is brought to you in partnership with CA Technologies.  Create app backends instantly with REST APIs and reactive logic using CA Live API Creator.

Topics:
python

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}