Skip to content

Commit

Permalink
fix: Bradford MDC
Browse files Browse the repository at this point in the history
fix: #984
  • Loading branch information
m26dvd committed Nov 10, 2024
1 parent 2ff004f commit 14f7a65
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions uk_bin_collection/uk_bin_collection/councils/BradfordMDC.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

import requests
from bs4 import BeautifulSoup

Expand Down Expand Up @@ -89,12 +91,40 @@ def parse_data(self, page: str, **kwargs) -> dict:
)
).strftime(date_format)

# Build data dict for each entry
dict_data = {
"type": bin_type,
"collectionDate": bin_date,
}
data["bins"].append(dict_data)
# Build data dict for each entry
dict_data = {
"type": bin_type,
"collectionDate": bin_date,
}
data["bins"].append(dict_data)

for bin in soup.find_all(attrs={"id": re.compile(r"CTID-D0TUYGxO-\d+-A")}):
dict_data = {
"type": "General Waste",
"collectionDate": datetime.strptime(
bin.text.strip(),
"%a %b %d %Y",
).strftime(date_format),
}
data["bins"].append(dict_data)
for bin in soup.find_all(attrs={"id": re.compile(r"CTID-d3gapLk-\d+-A")}):
dict_data = {
"type": "Recycling Waste",
"collectionDate": datetime.strptime(
bin.text.strip(),
"%a %b %d %Y",
).strftime(date_format),
}
data["bins"].append(dict_data)
for bin in soup.find_all(attrs={"id": re.compile(r"CTID-L8OidMPA-\d+-A")}):
dict_data = {
"type": "Garden Waste (Subscription Only)",
"collectionDate": datetime.strptime(
bin.text.strip(),
"%a %b %d %Y",
).strftime(date_format),
}
data["bins"].append(dict_data)

data["bins"].sort(
key=lambda x: datetime.strptime(x.get("collectionDate"), date_format)
Expand Down

0 comments on commit 14f7a65

Please sign in to comment.