尝试通过 Tor 发送请求requests[socks]
并在请求数量后更新 IP x
。
这是代码:
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的“a little relay”文章之后更改了我的torrc文件
edit2:尚未找到解决方案。