Get Cliet IP Address
eliasf
efotinis at oohay.com
Sun Aug 2 02:59:41 EDT 2009
"Fred Atkinson" wrote:
> What is the function to obtain the client browser's IP
> address?
Do you mean the external public IP to the Internet? When I wanted to log the
dynamic IP that my ADSL connection gets, I used whatismyip.com like this:
import urllib2
QUERY_URL = 'http://www.whatismyip.com/automation/n09230945.asp'
def query():
"""Get IP as a string.
As per the whatismyip.com automation rules, this function should not
be called more ofter than every 5 minutes.
"""
return urllib2.urlopen(QUERY_URL).read()
There's probably a better way, but I'm not very good with networking. :o)
More information about the Python-list
mailing list