How to get HTTPS content using Python Requests through TOR and Privoxy

自古美人都是妖i 提交于 2019-12-04 17:08:14
bija

HTTPS proxies are not yet properly supported by urllib3 (used by requests).

Please see requests issue 905 and urllib3 issue 50 for details.

Try requesocks, a fork of requests designed to connect directly to a SOCKS proxy (like Tor is, without ever using Privoxy in the first place. If you need Privoxy specifically, you may be out of luck, but otherwise, pip install requesocks and replace

import requests

with

import requesocks
requests = requesocks.session()
requests.proxies = {"http": "socks5://127.0.0.1:8118",
                   "https": "socks5://127.0.0.1:8118"}

Now, the requests variable is a session (with requests.get() and friends) that you can use in the exact same way as directly importing requests.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!