Why anyone thinks it's a good idea not to send API data to a python User-Agent is kind of beyond me but who knows...can't really complain since they provide data for free and I really was just playing around without actually needing to do anything productive.
Actually found a bug in urllib3 (that I probably should get around to reporting) -- page sends http unless you set Accept to 'application/json' which urllib3 doesn't let you do.
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).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.
http = urllib3.PoolManager()
r = http.request('GET', "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", headers={'Accept': 'application/json'})
r.headers['Content-Type'] 'text/html; charset=UTF-8'
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.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.