fix(poi-sync): add User-Agent header — Overpass returns 406 for python-httpx default UA
This commit is contained in:
parent
9742219ef6
commit
93f13795bb
1 changed files with 11 additions and 2 deletions
|
|
@ -64,10 +64,19 @@ def _classify(tags: dict[str, str]) -> str | None:
|
|||
|
||||
|
||||
async def fetch_overpass() -> list[dict]:
|
||||
"""Запросить Overpass API, вернуть список raw OSM elements."""
|
||||
"""Запросить Overpass API, вернуть список raw OSM elements.
|
||||
|
||||
NB: Overpass блокирует default `python-httpx/*` User-Agent (отдаёт 406).
|
||||
Передаём явный UA с контактом проекта — это требование Overpass usage
|
||||
policy (https://operations.osmfoundation.org/policies/api/).
|
||||
"""
|
||||
query = _build_overpass_query()
|
||||
logger.info("Overpass: отправляем запрос (%d символов)", len(query))
|
||||
async with httpx.AsyncClient(timeout=120) as client:
|
||||
headers = {
|
||||
"User-Agent": "GenDesign-SiteFinder/1.0 (+https://gendsgn.ru)",
|
||||
"Accept": "application/json",
|
||||
}
|
||||
async with httpx.AsyncClient(timeout=120, headers=headers) as client:
|
||||
r = await client.post(OVERPASS_URL, data={"data": query})
|
||||
r.raise_for_status()
|
||||
elements: list[dict] = r.json().get("elements", [])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue