You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wolfsburg updated the way to search for your waste dates. It used the city or district (for paper, organic waste and residual waste) and the street (for plastic).
But since the update they are forwarding you to another domain were only the street ist used.
The text was updated successfully, but these errors were encountered:
I'm not a Programmer.
I just tinkerd around. To be honest i asked ChatGPT5 to help. After some try and error "we" came up with this code. It seems like it works fine.
Here the Code:
from datetime import date, datetime
import requests
from bs4 import BeautifulSoup, Tag
from waste_collection_schedule import Collection # type: ignore[attr-defined]
TITLE = "Wolfsburger Abfallwirtschaft und Straßenreinigung"
DESCRIPTION = "Source for waste collections for WAS-Wolfsburg, Germany."
URL = "https://waswob.de" # Neue URL
TEST_CASES = {
"Kattowitzer Str.": {"street": "Kattowitzer Str."},
"Heinrich-Nordhoff-Str.": {"street": "Heinrich-Nordhoff-Str."},
}
ICON_MAP = {
"Gelber Sack": "mdi:recycle",
"Bioabfall": "mdi:leaf",
"Restabfall": "mdi:trash-can",
"Altpapier": "mdi:file-document-outline",
}
class Source:
def __init__(self, street: str | None):
self._street = street
if street is None:
raise ValueError("Street must be set")
def fetch(self) -> list[Collection]:
"""
Fetch waste collection data for the specified street.
"""
if not self._street:
raise ValueError("Street must be provided to fetch data.")
# URL der JSON-API
url = f"https://abfuhrtermine.waswob.de/php/abfuhrtermineeingabe.php?k={self._street.replace(' ', '%20')}"
try:
# Daten abrufen
response = requests.get(url)
response.raise_for_status() # Fehler prüfen
data = response.json() # JSON-Inhalt parsen
except requests.RequestException as e:
raise RuntimeError(f"Error fetching data: {e}")
except ValueError:
raise RuntimeError("Invalid JSON response from the server.")
# Ergebnisse verarbeiten
entries = []
for entry in data:
try:
waste_type = entry.get("waste", "Unbekannt").title() # Großbuchstaben anwenden
date_str = entry.get("date", "01.01.1970") # Fallback-Datum
collection_date = datetime.strptime(date_str, "%d.%m.%Y").date()
# Icon zuordnen
icon = ICON_MAP.get(waste_type, "mdi:trash-can")
# Sammlung hinzufügen
entries.append(Collection(date=collection_date, t=waste_type, icon=icon))
except Exception as e:
print(f"Error processing entry: {entry}, {e}")
return entries
Municipality / Region
Wolfsburg, Germany
Collection Calendar Webpage
https://was-wolfsburg.de/ or https://abfuhrtermine.waswob.de/
Example Address
City: Barnstorf
Street: Bahnhofspassage
Collection Data Format
As html on a webpage
Additional Information
Wolfsburg updated the way to search for your waste dates. It used the city or district (for paper, organic waste and residual waste) and the street (for plastic).
But since the update they are forwarding you to another domain were only the street ist used.
The text was updated successfully, but these errors were encountered: