I have an issue with requests lib :
With a code like
requests.get("HTTPS://api.twitch.tv/helix/...", headers = headers)
,
with the information that twitch API needs in the variable "headers".
And unfortunately, with except Exception, e: print(e)
I get ('Connection aborted.', BadStatusLine("''",))
.
I already tried to fake my user agent.
I'm almost sure that it isn't from server (Twitch) because I also use the ancient API and I have the same bug, while I already used it successfully (Since that, I reseted my Raspberry, it may can explain...).
It doesn't do this error every requests, but like 1 on 10 so it's a bit embarrassing.
I also have this error only with Raspbian, but not with Windows.
Thanks for helping me, a young lost coder.
There are a lot of reasons for this error and main of them is - you violate Twitch's user policy (which directly prohibit using scrapers) and server banned some of your requests.
You should try to use sessions when you access site:
session = requests.Session()
and use session.get
instead of requests.get
Another things to try are limit your requests rate and rotate different sessions with different headers (don't mix headers and sessions).