3 ms·
Eh, maybe... http = urllib3.PoolManager() r = http.request('GET', "https://oneom.tk/data/config" https://oneom.tk/data/config", headers={'Accept': 'applicatio
by UncleEntity 9y ago
Eh, maybe...
http = urllib3.PoolManager()
r = http.request('GET', "https://oneom.tk/data/config" https://oneom.tk/data/config", headers={'Accept': 'application/json', 'User-Agent' : "Mozilla/5.0"})
r.headers['Content-Type']
'application/json'
r = http.request('GET', "https://oneom.tk/data/config" https://oneom.tk/data/config", headers={'Accept': 'application/json'})
r.headers['Content-Type']
'text/html; charset=UTF-8'
- haikuginger 9y agoIt looks like this API in particular expects all requests to have a User-Agent header, and we don't set one by default. Setting any user agent appears to work; the issue isn't with the `Accept` header. You can reproduce with curl with the following command: curl -v 'https://oneom.tk/data/config' -H 'Accept: application/json' -H 'User-Agent:' That'll nullify the default curl user agent and should produce the same results you were seeing with urllib3.
- UncleEntity 9y agoThat makes sense, I kind of figured they were doing something screwy. I'm guessing a blacklist on certain User-Agent settings. When I was messing with it I could get it to work with curl and (eventually) urllib but urllib3 was no bueno until I tried to reproduce the problem and just copied the header with the User-Agent field from the urllib code.