有 Python 与 Tor 的绑定吗?
许多人已经展示了如何在 Python 中使用 Tor,如下所示:
proxy_support = urllib2.ProxyHandler({"http" : "127.0.0.1:8118"})
opener = urllib2.build_opener(proxy_support)
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
print opener.open(url).read()
然而,我正在寻找与 Tor 的 python 绑定, 将其集成到我的应用程序中。
我的意思是,用户不需要下载和安装 再次配置 Tor。
这将非常有用,请帮忙。
谢谢。
Many people have shown how to use Tor in Python like this:
proxy_support = urllib2.ProxyHandler({"http" : "127.0.0.1:8118"})
opener = urllib2.build_opener(proxy_support)
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
print opener.open(url).read()
However, I'm hunting for a python bindings to Tor,
that to be integrated into my App.
I mean, users will not need to download and install and
configure Tor again.
That would be very useful, help please.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有一些 python 库,最常见的是 stem 和 txtorcon。至于通过 Tor 引导流量,您可能会发现 Stem 的客户端使用教程很有帮助。
There are a few python libraries, the most common ones being stem and txtorcon. As for directing traffic over tor, you might find stem's client usage tutorial to be helpful.
您可以使用 tor 控制端口来设置 tor,没有任何到 tor 的绑定的原因是因为 tor 实际上已经有一个 API。您仍然需要使用 tor 作为 SOCKS 代理,大多数 python 库对此支持不是很好。
You can use the tor control port to setup tor, the reason there aren't any bindings to tor is because tor effectively already has an API. You would still need to use tor as a SOCKS proxy, which most python libraries don't support very well.
如果依赖 Twisted 没问题,您可以尝试 txtorcon 库,它通过控制端口与 Tor 通信。它支持隐藏服务的端点 API,具有文档、示例和 95% 以上的单元测试覆盖率。持续更新的状态(即 Tor 的当前状态,包括流、电路等)和配置(设置和读取)有抽象。
它确实依赖于本地安装的 tor——也就是说,“tor”必须位于路径中,或者必须已经在运行并侦听控制连接。如果您使用的是基于 debian 的系统,“apt-get install tor”就足以满足这两个要求。
If depending on Twisted is fine, you can try the txtorcon library which speaks to Tor via the control port. It supports the endpoints API for hidden services, has documentation, examples and 95%+ unit-test coverage. There are abstractions for continuously-updated state (i.e. the current state of Tor, with streams, circuits, etcetera) and configuration (setting and reading).
It does depend upon a locally installed tor -- that is, "tor" must be in the path, OR must already be running and listening for control connections. If you're on a debian-based system "apt-get install tor" is sufficient for both of these to be satisfied.