gpt4 book ai didi

python - 在 Python 2.6 上使用 Twython 的 SSL 未知协议(protocol)错误

转载 作者:太空宇宙 更新时间:2023-11-03 15:02:37 26 4
gpt4 key购买 nike

我正在尝试在代理后面运行 Twython。以下是 client_args:

client_args = {
'verify': False,
'headers': {
'User-Agent': 'AgentName'
},
'proxies': {
'http': 'proxy:port_number',
'https': 'proxy:port_number'
},
'timeout': 120
}

从 API 运行任何内容都会遇到此错误:

[Errno 1] _ssl.c:503: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

非常感谢任何解决方法!

最佳答案

您遇到了 Requests 的问题之一这是它无法处理 CONNECT HTTP 命令,主要是因为 urllib3不支持它。 This article更详细地说明了这个原因以及为什么 urllib3 没有更新来处理这个问题。这篇文章还包含一个不安全(并且不推荐)的解决方法,您可以尝试:

proxies = {'https': 'http://127.0.0.1:8080'}

显然用代理服务器的任何设置替换 IP 和端口。

您可能还想看看 this question ,它解决了与 httplib 相同的错误以及一些在那里工作并且可能适用的解决方案。也许吧。

编辑:您在第二个代理之后缺少逗号。

关于python - 在 Python 2.6 上使用 Twython 的 SSL 未知协议(protocol)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19143251/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com