How to get IP address

Levente Sandor sandorlevi at yahoo.com
Mon Mar 3 17:04:29 CET 2003


To do it in a pythonic manner, you can use the XML format information
at http://xml.showmyip.com :

from httplib import HTTPConnection
from xml.dom.ext.reader.Sax import FromXmlStream
conn = HTTPConnection('xml.showmyip.com')
conn.request('GET', '/')
doc = FromXmlStream(conn.getresponse())
print doc.getElementsByTagName('ip')[0].firstChild.data
conn.close()

----
levi

Nagy László Zsolt <nagylzs at freemail.hu> wrote in message news:<mailman.1046683091.23275.python-list at python.org>...
> Levente Sandor wrote:
> 
> >If you want to determine your external IP, AFAIK, you must ask a
> >machine that's external to your network. The simplest way is to visit
> >http://www.showmyip.com/
> >
> >----
> >levi
> >  
> >
> Connecting to an external address really works.
> 
> This site (http://www.showmyip.com/) is wonderful! :-)
> 
> Thank you for all the help. 
> 
>   Laci 1.0




More information about the Python-list mailing list