4 ms·
You should be able to add headers to your request. I set my user agent as such: import urllib.request as rq req = rq.Request(url, headers={'User-Agent': u
by gkya 9y ago
You should be able to add headers to your request. I set my user agent as such:
import urllib.request as rq
req = rq.Request(url, headers={'User-Agent': useragent})
request = rq.urlopen(req, timeout=timeout)
You should be able to set Accept in a similar fashion (tho IDK if urllib mandates a certain value for that header).
- UncleEntity 9y agoYeah, it works in urllib but not in urllib3. IIRC 'User-Agent' wasn't the problem but trying to set 'Accept' is what failed (and even more strangely they only do User-Agent filtering on API calls but not for http). I started to dig into the code but since I got it to work in urllib I left it as Someone Else's Problem.
- gkya 9y agoOh, alright then. I didn't know urllib3 was a different thing. I'm recently returning to python after some years, still catching up with all the new things.