试图通过Tor发送requests[socks]
请求,并在x
请求量之后续订IP
代码如下:
def tor():
session = requests.session()
session.proxies = {'http': 'socks5://127.0.0.1:9050',
'https': 'socks5://127.0.0.1:9050'}
return session
session = tor()
def renew_tor_ip():
with Controller.from_port(port = 9050) as controller:
controller.authenticate(password="mypassword")
controller.signal(Signal.NEWNYM)
def get_dorks(pages):
for i in range(pages):
i += 1
if i == 0:
s = session.get("url")
if i != 0:
s = session.get("url" + str(i))
if i == 20:
renew_tor_ip()
当我运行这个时
stem.connection.IncorrectSocketType: unable to use the control socket
编辑:在stem的“一个小继电器”文章之后,我更改了我的TORC文件
edit2:尚未找到解决方案
9050不是控制器的端口。 9051是您正在寻找的端口
改变
with Controller.from_port(port = 9050) as controller
到with Controller.from_port(port = 9051) as controller
您还必须在tor的配置文件中启用端口
相关问题 更多 >
编程相关推荐