I’m using the python package
requests to send requests to https://mobile.twitter.com/username/following.
At first, I encounter the exception : requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol. To solve that, I follow this solution to write a SSLAdapter to specify PROTOCOL_TLSv1.
After that, I encounter another exception : requests.exceptions.SSLError: [Errno bad handshake] (-1, 'Unexpected EOF’). And, I found this, but i send request and receive data in the same process.
And then, I use
requests to send requests to https://api.twitter.com/1.1/friends/ids.json. The second exception is gone(still didn’t understand why). But I encounter third exception : OpenSSL.SSL.SysCallError: (104, ‘Connection reset by peer’). I found this in SO. And I add
time.sleep(10) before send requests. But the third exception still happen.
So the second and the third exception still happen. Maybe the response content is too big too read? Or it’s the problem of twitter server(some SO solutions said about it ).
the code send requests to
https://mobile.twitter.com/username/followers is in here
and the code send requests to twitter rest api
followers/ids is in here