import urllib.request import urllib.parse import json import sys if sys.platform == "win32" and hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8") query = """ [out:json][timeout:60]; area["name"="Amsterdam"]["admin_level"="8"]->.a; ( node["amenity"~"restaurant|cafe|fast_food|bar|pub|ice_cream"](area.a); node["shop"~"bakery|seafood|pastry|deli"](area.a); way["amenity"~"restaurant|cafe|fast_food|bar|pub|ice_cream"](area.a); ); out center; """ print("Querying Overpass for complete Amsterdam municipality...") req = urllib.request.Request( "https://overpass-api.de/api/interpreter", data=f"data={urllib.parse.quote(query)}".encode("utf-8"), headers={"User-Agent": "PalateAmsterdamFullCoverage/1.0"} ) try: with urllib.request.urlopen(req, timeout=90) as resp: raw = resp.read().decode("utf-8") data = json.loads(raw) elements = data.get("elements", []) print(f"Success! Total elements returned for all Amsterdam: {len(elements)}") except Exception as e: print(f"Error querying Overpass: {e}")