DenisCarriere / geocoder

:earth_asia: Python Geocoder
http://geocoder.readthedocs.org
MIT License
1.63k stars 287 forks source link

geocoder.osm error cod 403 #471

Open rsjane opened 7 months ago

rsjane commented 7 months ago

When using geocoder.osm('Berlin'), python returns an error.

Status code 403 from https://nominatim.openstreetmap.org/search: ERROR - 403 Client Error: Forbidden for url: https://nominatim.openstreetmap.org/search?q=Berlin&format=jsonv2&addressdetails=1&limit=1

BrushXue commented 7 months ago

Same here (only on Windows computer). On macOS everything's working as usual.

shengrenTWR commented 5 months ago

Add the following function in the class OsmQuery(MultipleResultsQuery) in osm.py def _build_headers(self, provider_key, **kwargs): """Will be overridden according to the targetted web service""" return {"User-Agent": 'My User Agent 1.0'} This should be work. Reference: https://help.openstreetmap.org/questions/74205/nominatim-usage-policy-http-referers-and-user-agents