我正在尝试通过我的脚本更改TOR ip。 我很高兴在新的一年里制作NEWNYM:
from stem.connection import connect_port
from stem import Signal
from stem.control import Controller
def connectTor():
controller = connect_port(address='127.0.0.1', port=9150)
controller.connect_port()
controller.authenticate()
controller.signal(Signal.NEWNYM)
获取错误:
TypeError: __init__() takes exactly 2 arguments (3 given)
我做错了什么?你能帮助我吗?谢谢!
UPD:完全追溯:
Traceback (most recent call last):
File "D:/python/projects/tor/main.py", line 33, in <module>
connectTor()
File "D:/python/projects/tor/main.py", line 15, in connectTor
controller = connect_port(port=9150)
File "C:\Python27\32\lib\site-packages\stem\connection.py", line 171, in connect_port
control_port = stem.socket.ControlPort(address, port)
File "C:\Python27\32\lib\site-packages\stem\socket.py", line 350, in __init__
self.connect()
File "C:\Python27\32\lib\site-packages\stem\socket.py", line 223, in connect
self._socket = self._make_socket()
File "C:\Python27\32\lib\site-packages\stem\socket.py", line 376, in _make_socket
control_socket.connect((self._control_addr, self._control_port))
File "D:\python\projects\tor\socks.py", line 369, in connect
self.__negotiatesocks5(destpair[0],destpair[1])
File "D:\python\projects\tor\socks.py", line 236, in __negotiatesocks5
raise Socks5Error(ord(resp[1]),_generalerrors[ord(resp[1])])
TypeError: __init__() takes exactly 2 arguments (3 given)
P.S。抱歉我的英语不好......
答案 0 :(得分:0)
connect_port()方法为您提供了一个Controller实例。控制器反过来没有自己的'connect_port()'方法,所以我很惊讶“controller.connect_port()”行没有跟踪。
不鼓励重复使用您的IP,因为它会危害网络。请看......
https://stem.torproject.org/faq.html#how-do-i-request-a-new-identity-from-tor