From 8abaafa87e1116fcfeb3a42c2133cf1a0d1308a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 19 Mar 2020 18:55:05 +0100 Subject: [PATCH] Total row changed too --- custom_components/coronavirus_hessen/__init__.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/custom_components/coronavirus_hessen/__init__.py b/custom_components/coronavirus_hessen/__init__.py index 205fe68..a3ebc8e 100644 --- a/custom_components/coronavirus_hessen/__init__.py +++ b/custom_components/coronavirus_hessen/__init__.py @@ -73,8 +73,7 @@ async def async_get_data(): result = dict() rows = data.select("article table:first-of-type tr") - # Counties - for row in rows[1:-1]: + for row in rows[1:]: line = row.select("td") if len(line) != 3: continue @@ -89,14 +88,10 @@ async def async_get_data(): except ValueError: _LOGGER.error("Error processing line {}, skipping".format(line)) continue - result[county] = cases - # Total - line = rows[-1].select("td") - try: - result[OPTION_TOTAL] = int(line[-1].select("p strong")[0].text.strip()) - except ValueError: - _LOGGER.error("Error processing total value from {}, skipping".format(line)) + if county == "Gesamt": + county = OPTION_TOTAL + result[county] = cases _LOGGER.debug("Corona Hessen: {!r}".format(result)) return result