python_tor_proxy
1.0
Proxtor是一个Python库,可让您通过TOR网络发送HTTP请求。它简化了与TOR的互动,并有助于IP续订,发送/发布请求等。
可以使用PIP安装代理:
pip install ProxtorProxtor需要在计算机上安装TOR并运行。它还假设TOR控制端口设置为9051,并且将密码设置为“ Your_password”(初始化Proxtor时可以更改密码和端口)。
该包在Python3.11中编写,但应与任何版本的Python 3.7+一起使用。
这里有Docker映像。
如果您想做更多自定义的事情,则可以在存储库中提供一个示例Dockerfile。
代理非常易于使用。这是如何使用它的示例:
from Proxtor import Tor
tor = Tor ( tor_password = 'your_password' , tor_port = 9051 )
# Get request
response = tor . get_request ( url = 'https://example.com' , headers = { 'User-Agent' : 'Mozilla/5.0' })
print ( response . content )
# Post request
response = tor . post_request ( url = 'https://example.com' , headers = { 'User-Agent' : 'Mozilla/5.0' }, data = { 'key' : 'value' })
print ( response . content )
# Get the current IP
# Tor ip
print ( tor . get_ip ())
# Local machine ip
print ( tor . get_ip ( show_tor_ip = False ))
# Get a new IP (won't work 100% of the time as it depends on the exit node)
tor . get_new_ip ( max_retries = 5 )默认情况下启用了日志记录,将日志级别设置为信息。您会找到关键事件的日志,例如TOR IP续订失败。
贡献非常欢迎。请提交拉动请求或为任何增强功能,错误或功能请求创建问题。
该项目已根据MIT许可获得许可。有关详细信息,请参见许可证文件。