mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 02:04:22 +01:00
Add check for missing collection dates
This commit is contained in:
committed by
5ila5
parent
4379e19fb4
commit
78289d7636
@@ -29,7 +29,6 @@ class Source:
|
||||
self._uprn = str(uprn)
|
||||
|
||||
def fetch(self):
|
||||
|
||||
s = requests.Session()
|
||||
r = s.get(
|
||||
f"https://exeter.gov.uk/repositories/hidden-pages/address-finder/?qsource=UPRN&qtype=bins&term={self._uprn}"
|
||||
@@ -41,15 +40,17 @@ class Source:
|
||||
dates = soup.findAll("h3")
|
||||
|
||||
entries = []
|
||||
for (b, d) in zip(bins, dates):
|
||||
entries.append(
|
||||
Collection(
|
||||
date=datetime.strptime(
|
||||
re.compile(REGEX_ORDINALS).sub("", d.text), "%A, %d %B %Y"
|
||||
).date(),
|
||||
t=b.text.replace(" collection", ""),
|
||||
icon=ICON_MAP.get(b.text.replace(" collection", "").upper()),
|
||||
for b, d in zip(bins, dates):
|
||||
# check cases where no date is given for a collection
|
||||
if d and len(d.text.split(",")) > 1:
|
||||
entries.append(
|
||||
Collection(
|
||||
date=datetime.strptime(
|
||||
re.compile(REGEX_ORDINALS).sub("", d.text), "%A, %d %B %Y"
|
||||
).date(),
|
||||
t=b.text.replace(" collection", ""),
|
||||
icon=ICON_MAP.get(b.text.replace(" collection", "").upper()),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
|
||||
Reference in New Issue
Block a user