How to get the Tor ExitNode IP with Python and Stem
Question: I'm trying to get the external IP that Tor uses, as mentioned
[here](http://stackoverflow.com/questions/9777192/how-do-i-get-the-tor-exit-
node-ip-address-over-the-control-port). When using something like
myip.dnsomatic.com, this is very slow. I tried what was suggested in the
aforementioned link (python + stem to control tor through the control port),
but all you get is circuit's IPs with no assurance of which one is the one on
the exitnode, and, sometimes the real IP is not even among the results.

Any help would be appreciated.

Also, from [here](http://stackoverflow.com/questions/1096379/tor-with-python),
at the bottom, Amine suggests a way to renew the identity in Tor. There is an
instruction, **controller.get_newnym_wait()** , which he uses to wait until
the new connection is ready (controller is from Control in steam.control),
isn't there any thing like that in Steam (sorry, I checked and double/triple
checked and couldn't find nothing) that tells you that Tor is changing its
identity?


Answer: You can use this code for check current IP (change SOCKS_PORT value to yours):

    
    
    import re
    
    import stem.process
    import requesocks
    
    SOCKS_PORT = 9053
    
    tor_process = stem.process.launch_tor()
    proxy_address = 'socks5://127.0.0.1:{}'.format(SOCKS_PORT)
    proxies = {
                'http': proxy_address,
                'https': proxy_address
            }
    response = requesocks.get("http://httpbin.org/ip", proxies=proxies)
    print re.findall(r'[\d.-]+', response.text)[0]
    tor_process.kill()
    

