Skip to content

Commit

Permalink
Add check for missing collection dates
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneNulschDE authored and 5ila5 committed Jan 23, 2024
1 parent 4379e19 commit 78289d7
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(self, uprn):
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}"
Expand All @@ -41,15 +40,17 @@ def fetch(self):
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

0 comments on commit 78289d7

Please sign in to comment.