From b8b42b14405bb4e447fe899621baa12526b5a502 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sat, 4 May 2024 08:50:19 +0000 Subject: [PATCH 1/2] Correct code location in user agent string --- matcher/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/matcher/__init__.py b/matcher/__init__.py index 80c2c41..e389a0a 100644 --- a/matcher/__init__.py +++ b/matcher/__init__.py @@ -1,12 +1,9 @@ """Match OSM and Wikidata items.""" - CallParams = dict[str, str | int] user_agent = ( - "osm-wikidata/0.2" - + " (https://github.com/EdwardBetts/osm-wikidata;" - + " edward@4angle.com)" + "osm-wikidata/0.2 (https://git.4angle.com/edward/owl-map; edward@4angle.com)" ) From fc34c2bdcf498cd994ad13a5f20ed167466da58c Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sat, 4 May 2024 08:51:15 +0000 Subject: [PATCH 2/2] Pass User-Agent header when calling nominatim --- matcher/nominatim.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matcher/nominatim.py b/matcher/nominatim.py index c15b8fc..f065625 100644 --- a/matcher/nominatim.py +++ b/matcher/nominatim.py @@ -6,7 +6,7 @@ from collections import OrderedDict import requests -from . import CallParams +from . import CallParams, user_agent_headers Hit = dict[str, typing.Any] @@ -28,7 +28,7 @@ def lookup_with_params(**kwargs: str) -> list[Hit]: "polygon_text": 0, } params.update(kwargs) - r = requests.get(url, params=params) + r = requests.get(url, params=params, headers=user_agent_headers()) if r.status_code == 500: raise SearchError