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許可獲得許可。有關詳細信息,請參見許可證文件。