我想在 Tor 的帮助下使用 python 3 发出匿名网络请求,我正在关注本教程:https ://computerscienceandfangs.blogspot.com/2018/04/setting-up-tor-for-windows-10- python-3.html。
到目前为止,我只是在测试教程代码的第一部分(如下):
import requests
def get_tor_session():
session = requests.session()
# Tor uses the 9050 port as the default socks port
session.proxies = {'http': 'socks5://127.0.0.1:9050',
'https': 'socks5://127.0.0.1:9050'}
return session
# Make a request through the Tor connection
# IP visible through Tor
session = get_tor_session()
print(session.get("http://httpbin.org/ip").text)
# Above should print an IP different than your public IP
# Following prints your normal public IP
print(requests.get("http://httpbin.org/ip").text)
因此,当我执行 code:print(session.get("http://httpbin.org/ip").text)
时,它应该向我显示一个不同的 IP 地址。但是,我得到了错误:
File "C:\Program Files\Anaconda3\lib\site-packages\requests\adapters.py", line 43, in SOCKSProxyManager
try:
InvalidSchema: Missing dependencies for SOCKS support.
我已经按照教程安装了以下软件包:
1)pip 安装请求——升级
2)pip 安装请求[socks]
3)点安装阀杆
我使用的是 Windows 7(64 位)。用于 Python IDE 的 Spyder。Python 3.5 版。
第二个问题,更笼统。作为网络抓取工具项目的一部分,我希望提出更大规模的请求。上面的方法,使用我引用的教程,仍然是一个很好的方法(即使用 Python 手动编码),以确保你不会被禁止/黑名单?或者是否有更高级的服务可以为您执行匿名 IP 请求、IP 轮换和请求限制,而无需您编写自己的软件并手动配置,并且请求数量不受限制?
提前谢谢了。