autobahn api data

main
Roman Schöne 2026-04-09 16:27:43 +02:00
parent 83b679b721
commit eeb1fe8b4a
6 changed files with 772999 additions and 0 deletions

View File

@ -0,0 +1,198 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "49d54764",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
"import time\n",
"\n",
"API_URL = \"https://verkehr.autobahn.de/o/autobahn/\""
]
},
{
"cell_type": "markdown",
"id": "76963637",
"metadata": {},
"source": [
"### Alle Straßennamen erhalten"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8638c916",
"metadata": {},
"outputs": [],
"source": [
"response = requests.get(API_URL)\n",
"\n",
"with open(\"data/autobahn.json\", mode=\"w+\", encoding=\"utf8\") as autobahn_file:\n",
" roads = json.loads(response.text)\n",
" autobahn_file.write(json.dumps(roads))"
]
},
{
"cell_type": "markdown",
"id": "b67e0048",
"metadata": {},
"source": [
"### Alle Baustellen erhalten"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "74e428ce",
"metadata": {},
"outputs": [],
"source": [
"total_roadworks = {}\n",
"\n",
"for i, road in enumerate(roads[\"roads\"]):\n",
" response = requests.get(f\"{API_URL}/{road}/services/roadworks\")\n",
" roadworks = json.loads(response.text)\n",
" total_roadworks[road] = roadworks\n",
" print(f\"{i}/{len(roads[\"roads\"])} Autobahnen\")\n",
" time.sleep(5)\n",
"\n",
"with open(\"data/roadworks.json\", mode=\"w+\", encoding=\"utf8\") as roadwork_file:\n",
" roadwork_file.write(json.dumps(total_roadworks))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5462f028",
"metadata": {},
"outputs": [],
"source": [
"roads[\"roads\"][88]"
]
},
{
"cell_type": "markdown",
"id": "7ea3d8bc",
"metadata": {},
"source": [
"### Alle Rastplätze erhalten"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eecd5da0",
"metadata": {},
"outputs": [],
"source": [
"total_parking_lorries = {}\n",
"\n",
"for i, road in enumerate(roads[\"roads\"]):\n",
" response = requests.get(f\"{API_URL}/{road}/services/parking_lorry\")\n",
" if response.status_code != 200:\n",
" continue\n",
" try:\n",
" parking_lorry = json.loads(response.text)\n",
" total_parking_lorries[road] = parking_lorry\n",
" print(f\"{i}/{len(roads[\"roads\"])} Autobahnen\")\n",
" except json.JSONDecodeError as e:\n",
" print(f\"{i} Error {str(e)} occured\")\n",
" time.sleep(3)\n",
"\n",
"with open(\"data/parkinglorries.json\", mode=\"w+\", encoding=\"utf8\") as parkinglorries_file:\n",
" parkinglorries_file.write(json.dumps(total_parking_lorries))"
]
},
{
"cell_type": "markdown",
"id": "ff2efc9f",
"metadata": {},
"source": [
"### Alle Ladestationen erhalten"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4a34ff23",
"metadata": {},
"outputs": [],
"source": [
"total_charging_stations = {}\n",
"\n",
"for i, road in enumerate(roads[\"roads\"]):\n",
" response = requests.get(f\"{API_URL}/{road}/services/electric_charging_station\")\n",
" if response.status_code != 200:\n",
" continue\n",
" try:\n",
" charging_station = json.loads(response.text)\n",
" total_charging_stations[road] = charging_station\n",
" print(f\"{i}/{len(roads[\"roads\"])} Autobahnen\")\n",
" except json.JSONDecodeError as e:\n",
" print(f\"{i} Error {str(e)} occured\")\n",
" time.sleep(3)\n",
"\n",
"with open(\"data/chargingstations.json\", mode=\"w+\", encoding=\"utf8\") as chargingstations_file:\n",
" chargingstations_file.write(json.dumps(total_charging_stations))"
]
},
{
"cell_type": "markdown",
"id": "6db81957",
"metadata": {},
"source": [
"### Alle Webcams"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "224db1fa",
"metadata": {},
"outputs": [],
"source": [
"total_webcams = {}\n",
"\n",
"for i, road in enumerate(roads[\"roads\"]):\n",
" response = requests.get(f\"{API_URL}/{road}/services/webcam\")\n",
" if response.status_code != 200:\n",
" continue\n",
" try:\n",
" webcam = json.loads(response.text)\n",
" total_webcams[road] = webcam\n",
" print(f\"{i}/{len(roads[\"roads\"])} Autobahnen\")\n",
" except json.JSONDecodeError as e:\n",
" print(f\"{i} Error {str(e)} occured\")\n",
" time.sleep(3)\n",
"\n",
"with open(\"data/webcams.json\", mode=\"w+\", encoding=\"utf8\") as webcam_file:\n",
" webcam_file.write(json.dumps(total_webcams))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv (3.14.4)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,113 @@
{
"roads": [
"A1",
"A2",
"A3",
"A4",
"A5",
"A6",
"A7",
"A8",
"A9",
"A10",
"A11",
"A12",
"A13",
"A14",
"A15",
"A17",
"A19",
"A20",
"A21",
"A23",
"A24",
"A25",
"A26",
"A27",
"A28",
"A29",
"A30",
"A31",
"A33",
"A36",
"A37",
"A38",
"A39",
"A40",
"A42",
"A43",
"A44",
"A45",
"A46",
"A48",
"A49",
"A52",
"A57",
"A59",
"A60",
"A60 ",
"A61",
"A62",
"A63",
"A64",
"A65",
"A66",
"A67",
"A70",
"A71",
"A72",
"A73",
"A81",
"A92",
"A93",
"A94",
"A95",
"A96",
"A98",
"A99",
"A100",
"A103",
"A111",
"A113",
"A115",
"A117",
"A143",
"A210",
"A215",
"A226",
"A255",
"A261",
"A270",
"A281",
"A320",
"A352",
"A369",
"A445",
"A448",
"A480",
"A485",
"A516",
"A524",
"A542",
"A553",
"A555",
"A559",
"A560",
"A562",
"A565",
"A620",
"A623",
"A640",
"A643",
"A64a",
"A650",
"A659",
"A661",
"A671",
"A831",
"A861",
"A864",
"A995",
"A99a"
]
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,329 @@
{
"A1": {
"webcam": []
},
"A2": {
"webcam": []
},
"A3": {
"webcam": []
},
"A4": {
"webcam": []
},
"A5": {
"webcam": []
},
"A6": {
"webcam": []
},
"A7": {
"webcam": []
},
"A8": {
"webcam": []
},
"A9": {
"webcam": []
},
"A10": {
"webcam": []
},
"A11": {
"webcam": []
},
"A12": {
"webcam": []
},
"A13": {
"webcam": []
},
"A14": {
"webcam": []
},
"A15": {
"webcam": []
},
"A17": {
"webcam": []
},
"A19": {
"webcam": []
},
"A20": {
"webcam": []
},
"A21": {
"webcam": []
},
"A23": {
"webcam": []
},
"A24": {
"webcam": []
},
"A25": {
"webcam": []
},
"A26": {
"webcam": []
},
"A27": {
"webcam": []
},
"A28": {
"webcam": []
},
"A29": {
"webcam": []
},
"A30": {
"webcam": []
},
"A31": {
"webcam": []
},
"A33": {
"webcam": []
},
"A36": {
"webcam": []
},
"A37": {
"webcam": []
},
"A38": {
"webcam": []
},
"A39": {
"webcam": []
},
"A40": {
"webcam": []
},
"A42": {
"webcam": []
},
"A43": {
"webcam": []
},
"A44": {
"webcam": []
},
"A45": {
"webcam": []
},
"A46": {
"webcam": []
},
"A48": {
"webcam": []
},
"A49": {
"webcam": []
},
"A52": {
"webcam": []
},
"A57": {
"webcam": []
},
"A59": {
"webcam": []
},
"A60": {
"webcam": []
},
"A60 ": {
"webcam": []
},
"A61": {
"webcam": []
},
"A62": {
"webcam": []
},
"A63": {
"webcam": []
},
"A64": {
"webcam": []
},
"A65": {
"webcam": []
},
"A66": {
"webcam": []
},
"A67": {
"webcam": []
},
"A70": {
"webcam": []
},
"A71": {
"webcam": []
},
"A72": {
"webcam": []
},
"A73": {
"webcam": []
},
"A81": {
"webcam": []
},
"A92": {
"webcam": []
},
"A93": {
"webcam": []
},
"A94": {
"webcam": []
},
"A95": {
"webcam": []
},
"A96": {
"webcam": []
},
"A98": {
"webcam": []
},
"A99": {
"webcam": []
},
"A100": {
"webcam": []
},
"A103": {
"webcam": []
},
"A111": {
"webcam": []
},
"A113": {
"webcam": []
},
"A115": {
"webcam": []
},
"A117": {
"webcam": []
},
"A143": {
"webcam": []
},
"A210": {
"webcam": []
},
"A215": {
"webcam": []
},
"A226": {
"webcam": []
},
"A255": {
"webcam": []
},
"A261": {
"webcam": []
},
"A270": {
"webcam": []
},
"A281": {
"webcam": []
},
"A320": {
"webcam": []
},
"A352": {
"webcam": []
},
"A369": {
"webcam": []
},
"A445": {
"webcam": []
},
"A448": {
"webcam": []
},
"A480": {
"webcam": []
},
"A485": {
"webcam": []
},
"A516": {
"webcam": []
},
"A524": {
"webcam": []
},
"A542": {
"webcam": []
},
"A553": {
"webcam": []
},
"A555": {
"webcam": []
},
"A559": {
"webcam": []
},
"A560": {
"webcam": []
},
"A562": {
"webcam": []
},
"A565": {
"webcam": []
},
"A620": {
"webcam": []
},
"A623": {
"webcam": []
},
"A640": {
"webcam": []
},
"A643": {
"webcam": []
},
"A64a": {
"webcam": []
},
"A650": {
"webcam": []
},
"A659": {
"webcam": []
},
"A661": {
"webcam": []
},
"A671": {
"webcam": []
},
"A831": {
"webcam": []
},
"A861": {
"webcam": []
},
"A864": {
"webcam": []
},
"A995": {
"webcam": []
},
"A99a": {
"webcam": []
}
}