Skip to main content
 首页 » 编程设计

python之使用 `requests` : requests. 异常向 Twitter 发送请求。SSLError : [Errno bad handshake] (-1, 'Unexpected EOF’ )

2025年05月04日8zhujiabin

我正在使用 python 包 requests 将请求发送到 https://mobile.twitter.com/username/following。

起初,我遇到异常:requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol。为了解决这个问题,我遵循这个 solution编写一个 SSLAdapter 来指定 PROTOCOL_TLSv1。

在那之后,我遇到了另一个异常:requests.exceptions.SSLError: [Errno bad handshake] (-1, 'Unexpected EOF')。而且,我找到了this , 但我在同一过程中发送请求和接收数据。

也许我发送请求的速度太快了?

请您参考如下方法:

你需要为 apache2 安装 mod_ssl