如何解决要使Tor ControlPort正常工作并且看不到端口9051?
我有一个脚本,可以更改为新的Tor身份。另请注意, torrc 文件具有以下文本: ControlPort 9051
import requests
import time
from stem import Signal
from stem.control import Controller
def get_current_ip():
session = requests.session()
# TO Request URL with SOCKS over TOR
session.proxies = {}
session.proxies['http']='socks5h://localhost:9050'
session.proxies['https']='socks5h://localhost:9050'
try:
r = session.get('http://httpbin.org/ip')
except Exception as e:
print (e)
else:
return r.text
def renew_tor_ip():
with Controller.from_port(port = 9051) as controller:
controller.authenticate()
controller.signal(Signal.NEWNYM)
if __name__ == "__main__":
for i in range(5):
print (get_current_ip())
renew_tor_ip()
time.sleep(5)
执行后,我可以从 get_current_ip()方法获取tor ip,但是 renew_tor_ip()会遇到此错误。
[Errno 10061] No connection could be made because the target machine actively refused it
尽管遵循以下说明,但我也看不到端口9051打开:https://stackoverflow.com/a/46303954
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。