From 381dceb10a3b75da8cfb652435890cb48349b216 Mon Sep 17 00:00:00 2001 From: Robert Bradley Date: Thu, 8 Aug 2024 07:03:17 +0000 Subject: [PATCH] fix: #771 Bolton bullet points on dates is now fixed --- .../uk_bin_collection/councils/BoltonCouncil.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/uk_bin_collection/uk_bin_collection/councils/BoltonCouncil.py b/uk_bin_collection/uk_bin_collection/councils/BoltonCouncil.py index 67cc88a999..1978612e27 100644 --- a/uk_bin_collection/uk_bin_collection/councils/BoltonCouncil.py +++ b/uk_bin_collection/uk_bin_collection/councils/BoltonCouncil.py @@ -1,4 +1,6 @@ import time +import re + from datetime import datetime from bs4 import BeautifulSoup @@ -80,7 +82,8 @@ def parse_data(self, page: str, **kwargs) -> dict: bin_type = " ".join(words).capitalize() date_list = item.find_all("p") for d in date_list: - next_collection = datetime.strptime(d.text.strip(), "%A %d %B %Y") + clean_date_str = re.sub(r'[^A-Za-z0-9 ]+', '', d.text.strip()) + next_collection = datetime.strptime(clean_date_str, "%A %d %B %Y") collections.append((bin_type, next_collection)) # Sort the text and list elements by date