From 5f6e1fc979d2de961a19d0c226f2ec5bf9335bdd Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 15 May 2019 12:25:39 +0000 Subject: [PATCH] Fix parsing of pollen count from the BBC weather website --- dave/modules/pollen.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dave/modules/pollen.py b/dave/modules/pollen.py index 0e7d5a6..0da1c47 100644 --- a/dave/modules/pollen.py +++ a/dave/modules/pollen.py @@ -20,13 +20,13 @@ res = get("https://www.bbc.co.uk/weather/{}".format(postcode)) soup = BeautifulSoup(res.text, "html.parser") - element = soup.find_all("div", class_="environmental-index pollen-index") + element = soup.find_all("div", class_="wr-c-environmental-data") if element: - pollen = element[0].find("span") + pollen = element[0].find("span", class_="wr-c-environmental-data__icon-text") if pollen: - text = pollen.text + text = {'L': 'low', 'M': 'medium', 'H': 'high'}[pollen.text] or pollen.text dave.config.redis.setex("pollen:{}".format(postcode), 1800, text) else: text = dave.config.redis.get("pollen:{}".format(postcode)) -- rgit 0.1.3