Fix parser
All checks were successful
Build and Publish / build_and_publish (push) Successful in 1m24s

This commit is contained in:
Nexus 2024-07-05 00:18:23 +01:00
parent da8423bb97
commit a3d03d3446

View file

@ -100,7 +100,6 @@ class ElectionCog(commands.Cog):
)
self.log.debug("Sent countdown message")
def process_soup(self, soup: BeautifulSoup) -> dict[str, list[int]] | None:
good_soups = list(soup.find_all(attrs={"data-testid": "election-banner-results-bar"}))
if not good_soups:
@ -109,13 +108,13 @@ class ElectionCog(commands.Cog):
results: dict[str, list[int]] = {}
for child_li in good_soup.children:
span = list(child_li.children)[-1]
try:
party, extra = child_li.get_text().strip().split(":", 1)
party, extra = span.get_text().strip().split(":", 1)
seats, extra = extra.split(",", 1)
seats = int(seats.split()[0])
change = -1
seats = change = int(seats.split()[0])
except ValueError:
self.log.error("failed to parse %r", child_li)
self.log.error("failed to parse %r", span)
continue
results[party] = [seats, change, 0]
# if not span: