Fix mansfield_vic_gov_au (#2096)

* fix mansfield_vic_gov_au

* reformatting

---------

Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
This commit is contained in:
Tatham Oddie
2024-05-21 00:36:24 +10:00
committed by GitHub
parent cdb90732ff
commit d412e3cc2b

View File

@@ -69,10 +69,13 @@ class Source:
for article in soup.find_all("article"):
waste_type = article.h3.string
icon = ICON_MAP.get(waste_type)
next_pickup = article.find(class_="next-service").string.strip()
if re.match(r"[^\s]* \d{1,2}\/\d{1,2}\/\d{4}", next_pickup):
next_pickup = article.find(class_="next-service").string
if next_pickup is None:
continue
date_match = re.search(r"\d{1,2}\/\d{1,2}\/\d{4}", next_pickup)
if date_match:
next_pickup_date = datetime.strptime(
next_pickup.split(sep=" ")[1], "%d/%m/%Y"
date_match.group(0), "%d/%m/%Y"
).date()
entries.append(
Collection(date=next_pickup_date, t=waste_type, icon=icon)