diff --git a/download-overpass.py b/download-overpass.py index 11d65aa..fd5e219 100644 --- a/download-overpass.py +++ b/download-overpass.py @@ -86,11 +86,16 @@ def query_overpass(query): """Send query to Overpass API and return JSON response, with retries.""" url = "https://overpass-api.de/api/interpreter" data = urllib.parse.urlencode({"data": query}).encode("utf-8") + req = urllib.request.Request( + url, + data=data, + headers={"Accept": "*/*", "User-Agent": "TheVillagesImport/1.0"}, + ) max_attempts = 3 for attempt in range(1, max_attempts + 1): try: - with urllib.request.urlopen(url, data=data, timeout=300) as response: + with urllib.request.urlopen(req, timeout=300) as response: return json.loads(response.read().decode("utf-8")) except urllib.error.HTTPError as e: try: