fix 2019 parsing
All checks were successful
Build and Publish / build_and_publish (push) Successful in 1m12s

This commit is contained in:
Nexus 2024-07-05 00:46:07 +01:00
parent 0874ad78e0
commit b8f73f3bef

View file

@ -128,32 +128,12 @@ class ElectionCog(commands.Cog):
self.log.error("failed to parse %r", span)
continue
results[party] = [seats, change, 0, 0]
# if not span:
# self.log.warning("%r did not have a 'span' element.", child_ul)
# continue
# text = span.get_text().replace(",", "")
# groups = SPAN_REGEX.match(text)
# if groups:
# groups = groups.groupdict()
# else:
# self.log.warning(
# "Found span element (%r), however resolved text (%r) did not match regex.",
# span, text
# )
# continue
# results[str(groups["party"]).strip()] = [
# int(groups["councillors"].strip()),
# int(groups["net"].strip()) * MULTI[groups["net_change"]],
# int(find_colour(child_ul.next["class"][0])[1:], base=16)
# ]
for child_li in good_soups[1].children:
span = list(child_li.children)[-1]
try:
party, extra = span.get_text().strip().split(":", 1)
seats, _ = extra.split(" ", 1)
seats = int(seats)
seats, _ = extra.strip().split(" ", 1)
seats = int(seats.strip())
except ValueError:
self.log.error("failed to parse %r", span)
continue