Geography: Set a better user-agent to access Wikidata

This commit is contained in:
Valentin Lorentz 2021-11-08 23:41:26 +01:00
parent 27c513135c
commit 0a6f598295
1 changed files with 6 additions and 1 deletions

View File

@ -110,7 +110,12 @@ LIMIT 1
def _query_sparql(query):
params = {"format": "json", "query": query}
url = SPARQL_URL + "?" + urllib.parse.urlencode(params)
content = utils.web.getUrlContent(url)
# Comply with https://meta.wikimedia.org/wiki/User-Agent_policy
headers = utils.web.defaultHeaders.copy()
headers["User-agent"] += " https://github.com/progval/Limnoria/ - Geography plugin"
content = utils.web.getUrlContent(url, headers=headers)
return json.loads(content)
def timezone_from_qid(location_qid):