问题描述
我正在尝试用 Python 控制 Tor.我已经在 stackoverflow 上阅读了有关此主题的其他几个问题,但没有人回答这个问题.
I'm attempting to control Tor with Python. I've read a couple of the other questions asked about this subject on stackoverflow but none of them answer this question.
我正在寻找一种方法,可以在运行命令时让 Tor 为您提供新身份"、新 IP 地址.我四处搜索,发现 TorCtl 模块是一种控制 Tor 的方法,但找不到获得新身份的方法.到目前为止,这是我至少连接到 Tor 的方法,但不能再进一步了.
I'm looking for a method to have tor give you a 'new identity', a new IP address, when the command is run. I've googled around and found the TorCtl module as a method for controlling tor, but can't find a way to get a new identity. Here's what I have so far for atleast connecting to tor, but can't get any farther.
from TorCtl import TorCtl
conn = TorCtl.connect(controlAddr="127.0.0.1", controlPort=9051, passphrase="123")
对此的任何帮助表示赞赏,如果有其他更好的模块,那么 TorCtl 也很棒!谢谢!
Any help on this is appreciated, if there are other modules better then TorCtl that'd be great too! Thank you!
推荐答案
幸运的是,我设法找到了一个与我想要的完全相同的 PHP 脚本,并在它的帮助下将其转换为在TorCtl.这就是未来需要它的任何人的样子!
Well, out of luck I managed to find a PHP script that did the exact same thing I wanted, and with the help of that I converted it to work in TorCtl. This is what it looks like for anyone else needing it in the future!
from TorCtl import TorCtl
conn = TorCtl.connect(controlAddr="127.0.0.1", controlPort=9051, passphrase="123")
TorCtl.Connection.send_signal(conn, "NEWNYM")
这篇关于Python - 控制 Tor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!