🏡 index : ~doyle/dave.git

author dave <dave@ip-172-26-11-212.eu-west-2.compute.internal> 2019-05-15 12:25:39.0 +00:00:00
committer Jordan Johnson-Doyle <jordan@doyle.la> 2019-05-15 13:27:21.0 +01:00:00
commit
5f6e1fc979d2de961a19d0c226f2ec5bf9335bdd [patch]
tree
41e8a4e6d36b19202a9f4d6e5a0f12e75abd075a
parent
8cddd9316a15f0688c405e53cae95b1216ac50bf
download
5f6e1fc979d2de961a19d0c226f2ec5bf9335bdd.tar.gz

Fix parsing of pollen count from the BBC weather website



Diff

 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))