Fam*_*der 2 python proxy tor python-requests
我在我的系统上使用Privoxy进行了TOR设置,经过测试并运行良好.我想要做的是通过此设置代理HTTPS请求,以便这些GET和POST通过TOR.下面是我可以生成的最简单的代码版本:
import requests
proxy = { 'http':'127.0.0.1:8118','https':'127.0.0.1:8118' }
r = requests.get('https://www.whatismyip.com/',proxies=proxy)
#r = requests.get('http://www.whatsmyip.org/')
print r
Run Code Online (Sandbox Code Playgroud)
使用HTTPS时,我没有获得响应正文(r.content为空),但我确实获得了200状态代码,我可以在Privoxy日志中看到请求.我在这个帖子中看到了一个错误,但似乎几个月前在Requests库中解决了这个问题.
我的privoxy设置是基本的设置,并通过添加以下两行来监听localhost:
forward-socks4a / localhost:9050 .
forward-socks5 / localhost:9050 .
Run Code Online (Sandbox Code Playgroud)
在这一点上,我不确定发生了什么,但我做的事似乎没有用.我在Python 2.6.5上使用最新的请求库和urllib3.