Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dinhard Switzerland #3868

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

DonPablo1010
Copy link

Add waste collection source for Municipality of Dinhard.

This adds support for waste collection in the municipality of Dinhard, Switzerland.
Supported waste types: regular waste (with holiday adjustments), organic waste (Grüngutabfuhr), and paper/cardboard collection.

Add waste collection source for Municipality of Dinhard - Contributor: DonPablo1010
Add "Dinhard" under "Switzerland"
@5ila5
Copy link
Collaborator

5ila5 commented Mar 6, 2025

I don't really like the hard coded holidays (they are only for 2025) and the ICS parsing could be a lot easier if you'd use the ICS service (from waste_collection_schedule.service import ICS). This does not really look that robust. At this point, you're probably better of requesting the search page and parsing the HTML with BeautifulSoup:

entries = []
r = requests.post(
    "https://www.dinhard.ch/verwaltung/veranstaltungen.html/167",
    data={
        "eventSearchParams.category": "12",
        "eventSearchParams.query": "",
        "eventSearchParams.dateFrom": "",
        "eventSearchParams.dateTo": "",
    },
)
r.raise_for_status()
soup = BeautifulSoup(r.text, "html.parser")
events = soup.select("div.mod-entry-header")
for event in events:
    title = event.select_one("h2").text
    date_str = event.select_one("time").attrs.get("datetime")
    if date_str is None:
        continue
    event_date = date.fromisoformat(date_str)
    entries.append(Collection(event_date, title))
return entries

Could not really test this as the site behaves very weirdly for me not shure whats up with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants