Getting external IP address

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Tue Mar 6 08:51:33 EST 2007


On Mon, 05 Mar 2007 09:02:44 +0000, Duncan Booth wrote:

> Try running it interactively and looking at the data you receive:
> 
>>>> conn = HTTPConnection('xml.showmyip.com')
>>>> conn.request('GET', '/')
> 
>>>> resp = conn.getresponse()
>>>> print resp
> <httplib.HTTPResponse instance at 0x00C58350>
>>>> data = resp.read()
>>>> print data
> <html><head><title>Object moved</title></head><body>
> 
> <h2>Object moved to <a href="http://www.showmyip.com/xml/">here</a>.
> </h2>
> 
> </body></html>

Ah! That's the clue I needed -- thanks.

> If you try connecting to 'www.showmyip.com' and requesting '/xml/' it 
> should work.

Thank you muchly! That seems to do the trick.


-- 
Steven.




More information about the Python-list mailing list