tor - Get new Ip in python -


i'm trying new ip via python.

i found script on stackoverflow:

import urllib2 torctl import torctl  proxy_support = urllib2.proxyhandler({"http" : "127.0.0.1:8118"}) opener = urllib2.build_opener(proxy_support)   def newid():     conn = torctl.connect(controladdr="127.0.0.1", controlport=9051, passphrase="123")     conn.send_signal("newnym")  in range(0, 10):     print "case "+str(i+1)     newid()     proxy_support = urllib2.proxyhandler({"http" : "127.0.0.1:8118"})     urllib2.install_opener(opener)     print(urllib2.urlopen("http://www.ifconfig.me/ip").read()) 

i have vidalia running , privoxy. have settings correctly set:

in system preference (on mac) :

web proxy (http): 127.0.0.1:8118 , same https

in privoxy config file have line:

 forward-socks5   /               127.0.0.1:9051 . 

and in settings of vidalia have:

image

though still when run code stuck on on case 1 , can't ip. log of vidalia:

may 04 19:15:27.381 [notice] new control connection opened. may 04 19:15:27.382 [notice] new control connection opened. may 04 19:15:33.709 [notice] new control connection opened. may 04 19:15:38.653 [notice] new control connection opened. may 04 19:15:57.382 [notice] new control connection opened. may 04 19:15:57.463 [notice] new control connection opened. may 04 19:15:57.464 [notice] new control connection opened. may 04 19:16:03.710 [notice] new control connection opened. may 04 19:16:19.656 [notice] new control connection opened. may 04 19:16:22.448 [notice] new control connection opened. may 04 19:16:22.569 [notice] new control connection opened. may 04 19:16:22.900 [notice] new control connection opened. may 04 19:16:27.382 [notice] new control connection opened. may 04 19:16:27.412 [notice] new control connection opened. may 04 19:16:27.413 [notice] new control connection opened. 

what doing wrong ?

edit:

when line in config file active can't load site .

apparently if wait long enough error:

urllib2.httperror: http error 503: forwarding failure 

this question seems come pretty (1, 2) added faq entry it. tor not support method cycling ip allow create new identity. please don't overdo though, puts high load on tor network.

torctl deprecated, here's example using stem...

from stem import signal stem.control import controller  controller.from_port(port = 9051) controller:   controller.authenticate()   controller.signal(signal.newnym) 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -