Python Code Snippet to Get External IP Address

Comments

3 comments posted
Page location change

what's my ip changed the location of this page, the correct snippet is

[code]
import urllib2

def get_external_ip():
ip = urllib2.urlopen("http://automation.whatismyip.com/n09230945.asp").read()
return ip
[/code]

Posted by Trcx528 (not verified) on Sat, 11/26/2011 - 16:15
Thanks. As it turns out, the

Thanks. As it turns out, the URL can be even simpler, and I have amended the code above to show this.

Posted by Jeet Sukumaran on Sat, 11/26/2011 - 18:02
It must be wrong.
This function returns Internal IP, not the external one.
Posted by Anonymous on Mon, 11/30/2009 - 13:07

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a biological visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.