Skip to content

Commit

Permalink
Merge pull request #704 from dp247/684-huntingdon-district-council-no…
Browse files Browse the repository at this point in the history
…-longer-working

Fix AttributeError on HuntingdonDistrictCouncil.py
  • Loading branch information
dp247 authored May 9, 2024
2 parents 96d1642 + ff58bab commit a30801d
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ def parse_data(self, page, **kwargs) -> None:

data = {"bins": []}

bin_types = ["Domestic", "Recycle", "Organic"]

for i, date in enumerate(soup.find("ul", class_="d-print-none").find_all("li")):
data["bins"].append(
{
"type": bin_types[i],
"collectionDate": datetime.strptime(date.find("strong").get_text(strip=True), "%A %d %B %Y").strftime(date_format)
}
)
no_garden_message = "Your property does not receive a garden waste collection"
results = soup.find("ul", class_="d-print-none").find_all("li")

for result in results:
if no_garden_message in result.get_text(strip=True):
continue
else:
data["bins"].append(
{
"type": ' '.join(result.get_text(strip=True).split(" ")[5:7]).capitalize(),
"collectionDate": datetime.strptime(result.find("strong").get_text(strip=True),
"%A %d %B %Y").strftime(date_format)
}
)

return data

0 comments on commit a30801d

Please sign in to comment.