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

fix geelongaustralia #1509

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import datetime

import requests
from bs4 import BeautifulSoup
from waste_collection_schedule import Collection
from bs4 import BeautifulSoup, Tag
from waste_collection_schedule import Collection # type: ignore[attr-defined]

TITLE = "City of Greater Geelong"
DESCRIPTION = "Source City of Greater Geelong rubbish collection"
Expand All @@ -16,16 +16,14 @@
},
}

API_URL = "https://www.geelongaustralia.com.au/recycling/calendar.aspx"
API_URL = "https://www.geelongaustralia.com.au/recycling/calendar/default.aspx"
ICON_MAP = {
"Garbage": "mdi:trash-can",
"Recycling": "mdi:recycle",
"Green waste": "mdi:leaf",
}

SUBMIT_ARGS = {
"__VIEWSTATE": "/wEPDwUJLTQyNjIwNzQ4D2QWAmYPZBYCAgMQZGQWDAIDD2QWAmYPZBYCAgcPFgIeB1Zpc2libGVoZAIJD2QWAgIBD2QWBAIFDxYCHgtfIUl0ZW1Db3VudAICFgRmD2QWAmYPFQEhPGEgaHJlZj0iL3NlcnZpY2VzLyI+U2VydmljZXM8L2E+ZAIBD2QWAmYPFQEvPGEgaHJlZj0iL3JlY3ljbGluZy8iPlJ1YmJpc2ggYW5kIHJlY3ljbGluZzwvYT5kAgcPD2QPEBYFZgIBAgICAwIEFgUWBB4MRGVmYXVsdFZhbHVlBQlyZWN5Y2xpbmceDlBhcmFtZXRlclZhbHVlZBYEHwIFDWNhbGVuZGFyLmFzcHgfA2QWBB8CZR8DZBYEHwIFGC9yZWN5Y2xpbmcvY2FsZW5kYXIuYXNweB8DZBYEHwJlHwNkFgUCAwID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UPZBYCZg8WAh8GBQFHZBgFBTBjdGwwMCRDb250ZW50Qm9keSRpdGVtX2NvbnRlbnQkcmNfZG9jcyRGb3JtVmlldzEPZ2QFLGN0bDAwJENvbnRlbnRCb2R5JGl0ZW1fbGhzJHJjX2RvY3MkRm9ybVZpZXcxD2dkBS9jdGwwMCRDb250ZW50Qm9keSRpdGVtX2NvbnRlbnQkY3RsMDAkRlZfQ29udGVudA8UKwAHZGRkZGQWAAIBZAUiY3RsMDAkQ29udGVudEJvZHkkaXRlbV9yaHMkRlZfUkhTQw8UKwAHZGRkZGQWAAIBZAUrY3RsMDAkQ29udGVudEJvZHkkaXRlbV9saHMkY3RsMDAkRlZfQ29udGVudA8UKwAHZGRkZGQWAAIBZAKhZlw0uGgO4LdUdrBzDshiDOw2iI5GbePZCTsL/iUd",
"__EVENTVALIDATION": "/wEdAAi1v/BZgywsL3/V3yFKLfWNZBX5iWrINZCTIN9tE69sRcbs9peHpCSlkn89rsDNb+DS+PfBHKwIo4qs1Fr/jJ7WM4KAc9RmsO1tKxkiJA80y7Ktly48GpdZ2UlIqyldRAU5vOA1BPVA7FJ9SzEknmazyRFIzomhJ8GA9IbI1ircqsNO0zEuXfJnjjE4pebV51+PQx49jYyfnuvLeBt+9djB",
"ctl00$ContentBody$BTN_SEARCH": "Search",
}

Expand All @@ -41,6 +39,26 @@ def __init__(
self._submit_args[ADDRESS_FIELD] = f"{self._address}"

def fetch(self):
s = requests.Session()
r = s.get(API_URL)
r.raise_for_status()

soup: BeautifulSoup = BeautifulSoup(r.text, "html.parser")

viewstate = soup.find("input", id="__VIEWSTATE")
eventvalidation = soup.find("input", id="__EVENTVALIDATION")

if (
not viewstate
or isinstance(viewstate, Tag)
or not eventvalidation
or isinstance(eventvalidation, Tag)
):
raise Exception("could not get valid data from geelongaustralia.com.au")

self._submit_args["__VIEWSTATE"] = str(viewstate["value"])

self._submit_args["__EVENTVALIDATION"] = str(eventvalidation["value"])

r = requests.post(API_URL, data=self._submit_args)
r.raise_for_status()
Expand Down
Loading