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

Commit

Permalink
Improve parsing to work around HTML quirks in source
Browse files Browse the repository at this point in the history
  • Loading branch information
foosel committed Apr 19, 2020
1 parent 4b627c4 commit d57f688
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions custom_components/coronavirus_hessen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ async def async_get_data():
result = dict()
rows = data.select("article table:first-of-type tr")

for row in rows[1:]:
for row in rows[2:]:
line = row.select("td")
if len(line) != 7:
continue

try:
county = line[0].text.strip()
cases = parse_num(line[1].text.strip())
hospitalized = parse_num(line[2].text.strip())
deaths = parse_num(line[3].text.strip())
county = line[0].get_text(" ", strip=True)
cases = parse_num(line[1].get_text(" ", strip=True))
hospitalized = parse_num(line[2].get_text(" ", strip=True))
deaths = parse_num(line[3].get_text(" ", strip=True))
except:
_LOGGER.exception("Error processing line {}, skipping".format(line))
continue
Expand Down

0 comments on commit d57f688

Please sign in to comment.