Skip to content
This repository was archived by the owner on Nov 19, 2021. It is now read-only.

Commit d57f688

Browse files
committed
Improve parsing to work around HTML quirks in source
1 parent 4b627c4 commit d57f688

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

custom_components/coronavirus_hessen/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ async def async_get_data():
7373
result = dict()
7474
rows = data.select("article table:first-of-type tr")
7575

76-
for row in rows[1:]:
76+
for row in rows[2:]:
7777
line = row.select("td")
7878
if len(line) != 7:
7979
continue
8080

8181
try:
82-
county = line[0].text.strip()
83-
cases = parse_num(line[1].text.strip())
84-
hospitalized = parse_num(line[2].text.strip())
85-
deaths = parse_num(line[3].text.strip())
82+
county = line[0].get_text(" ", strip=True)
83+
cases = parse_num(line[1].get_text(" ", strip=True))
84+
hospitalized = parse_num(line[2].get_text(" ", strip=True))
85+
deaths = parse_num(line[3].get_text(" ", strip=True))
8686
except:
8787
_LOGGER.exception("Error processing line {}, skipping".format(line))
8888
continue

0 commit comments

Comments
 (0)