29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
import asyncio
|
|
import httpx
|
|
import json
|
|
|
|
async def probe_rdw():
|
|
base_url = "https://opendata.rdw.nl/resource/m9d7-ebf2.json"
|
|
fuel_url = "https://opendata.rdw.nl/resource/8ys7-d773.json"
|
|
|
|
types = ["Personenauto", "Motorfiets", "Vrachtwagen"]
|
|
|
|
async with httpx.AsyncClient() as client:
|
|
for v_type in types:
|
|
print(f"\n{'='*20} {v_type.upper()} {'='*20}")
|
|
# 1. Lekérjük a fő adatokat (1 darabot, ami biztosan nem üres)
|
|
resp = await client.get(f"{base_url}?voertuigsoort={v_type}&$limit=1&$where=handelsbenaming IS NOT NULL")
|
|
if resp.status_code == 200 and resp.json():
|
|
main_data = resp.json()[0]
|
|
kenteken = main_data.get('kenteken')
|
|
|
|
# 2. Lekérjük hozzá az üzemanyag/motor adatokat a rendszám alapján
|
|
fuel_resp = await client.get(f"{fuel_url}?kenteken={kenteken}")
|
|
fuel_data = fuel_resp.json()[0] if fuel_resp.status_code == 200 and fuel_resp.json() else {}
|
|
|
|
# 3. Összefésüljük a kettőt a kiíratáshoz
|
|
combined = {**main_data, **{"FUEL_DATA": fuel_data}}
|
|
print(json.dumps(combined, indent=2))
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(probe_rdw()) |