如何通过socks代理使python请求工作 [英] How to make python Requests work via socks proxy
本文介绍了如何通过socks代理使python请求工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Python 脚本中使用了很棒的 Requests 库:
I'm using the great Requests library in my Python script:
import requests
r = requests.get("some-site.com")
print r.text
我想使用socks代理.但是 Requests 现在只支持 HTTP 代理.
I would like to use socks proxy. But Requests only supports HTTP proxy now.
我该怎么做?
推荐答案
现代方式:
pip install -U requests[socks]
然后
import requests
resp = requests.get('http://go.to',
proxies=dict(http='socks5://user:pass@host:port',
https='socks5://user:pass@host:port'))
这篇关于如何通过socks代理使python请求工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文