python - 如何通过 socks 代理使 python 请求工作

标签 python proxy socks python-requests

我正在使用很棒的 Requests我的 Python 脚本中的库:

import requests
r = requests.get("some-site.example")
print r.text

我想使用 socks 代理。但是Requests现在只支持HTTP代理。

我该怎么做?

最佳答案

现代方式:

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'))

关于python - 如何通过 socks 代理使 python 请求工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12601316/

相关文章:

python - pypy pickled 不能被 cpython unpickled

python - 如何限制堆大小?

android - Android 处理 SSL 的代理服务器

c# - RestSharp 可移植 RestClient 代理属性不起作用

perl - 将 NET::SMTP SSL/TLS 与 SOCKS 一起使用

python - 您可以在 PyCharm 中调试由 bash 脚本调用的 python 文件吗?

python - 如何将图像大小调整为 shape=(None, 321, 321, 3) 且名称 name=None 且 dtype=tf.float32

Java 代理 - 无法接收来自主机/套接字问题的响应

使用 Socks 的 Java JDBC 连接

python - 如何使用 python 请求通过另一个代理重试连接?