socks - TorCtl and Socksipy library raises exception in python -
i'm writing script in python.
script uses urllib2 read web pages.
i'm using socksipy force urllib2 use socks proxy (tor).
problem after setting socket.socket torctl doesn't work , raises exception.
code doesn't work (first newtorid() works , second fails!):
newtorid() #this works import socks import socket socks.setdefaultproxy(socks.proxy_type_socks5, "localhost", 9050) socket.socket = socks.socksocket newtorid() #this fails! newtorid defined this:
from torctl import torctl def newtorid(): conn = torctl.connect(passphrase="test") conn.send_signal("newnym") the exception is:
__init__() takes 2 arguments (3 given) traceback (most recent call last): file "script.py", line 97, in <module> newtorid() file "script.py", line 27, in newtorid conn.send_signal("newnym") attributeerror: 'nonetype' object has no attribute 'send_signal' what problem?
it's own code raising exception, not library. particularly,
torctl.connect(passphrase="test") is returning none second time, resulting in error when call .send_signal on result.
i assume newtorid() intended request new tor identity. should call torctl.connection.send_signal(conn, "newnym") new identity, rather trying create new connection each time. see python - controlling tor.
Comments
Post a Comment