From e1d68408fe15540a2567a1944c36bc814688adec Mon Sep 17 00:00:00 2001 From: FilHarr <49679000+FilHarr@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:44:35 +0000 Subject: [PATCH] Fix Salford_gov_uk source (#3221) * Fix Salford_gov_uk source * reformatting --------- Co-authored-by: 5ila5 <5ila5@users.noreply.github.com> --- .../source/salford_gov_uk.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/salford_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/salford_gov_uk.py index 2ca446569..071ffee56 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/salford_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/salford_gov_uk.py @@ -27,15 +27,17 @@ def __init__(self, uprn: int): self._uprn = uprn def fetch(self): + url = "https://www.salford.gov.uk/bins-and-recycling/bin-collection-days/your-bin-collections/" params = {"UPRN": self._uprn} - r = requests.get( - "https://www.salford.gov.uk/bins-and-recycling/bin-collection-days/your-bin-collections/", - params=params, - ) + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0" + } + + r = requests.get(url, params=params, headers=headers) r.raise_for_status() soup = BeautifulSoup(r.text, features="html.parser") - results = soup.find_all("div", {"class": "col-xs-12 col-md-6"}) + results = soup.find_all("div", {"class": "col-12 col-lg-6"}) entries = []