Get Cliet IP Address

eliasf efotinis at
Sun Aug 2 08:59:41 CEST 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 like this:

    import urllib2

    QUERY_URL = ''

    def query():
        """Get IP as a string.

        As per the 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