Just merge all the CSS into one
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 16s
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 16s
This commit is contained in:
parent
0ff3de0ea4
commit
16bd14bdc1
1 changed files with 4 additions and 4 deletions
|
@ -49,7 +49,7 @@ class ElectionCog(commands.Cog):
|
||||||
if not good_soup:
|
if not good_soup:
|
||||||
return
|
return
|
||||||
|
|
||||||
css: str = [x for x in good_soup.find_all("style") if "Results" in x.get_text()][0].get_text()
|
css: str = "\n".join([x.get_text() for x in good_soup.find_all("style") if "Results" in x.get_text()])
|
||||||
|
|
||||||
def find_colour(style_name: str, want: str = "background-colour") -> str | None:
|
def find_colour(style_name: str, want: str = "background-colour") -> str | None:
|
||||||
index = css.index(style_name) + len(style_name) + 1
|
index = css.index(style_name) + len(style_name) + 1
|
||||||
|
@ -58,13 +58,13 @@ class ElectionCog(commands.Cog):
|
||||||
if char == "}":
|
if char == "}":
|
||||||
break
|
break
|
||||||
value += char
|
value += char
|
||||||
attributes = filter(value.split(";"))
|
attributes = filter(None, value.split(";"))
|
||||||
parsed = {}
|
parsed = {}
|
||||||
for attr in attributes:
|
for attr in attributes:
|
||||||
name, val = attr.split(":")
|
name, val = attr.split(":")
|
||||||
parsed[name] = val
|
parsed[name] = val
|
||||||
if want in parsed:
|
if want in parsed:
|
||||||
return parsed[name]
|
return parsed[want]
|
||||||
|
|
||||||
results: dict[str, list[int]] = {}
|
results: dict[str, list[int]] = {}
|
||||||
for child_ul in good_soup.children:
|
for child_ul in good_soup.children:
|
||||||
|
@ -104,7 +104,7 @@ class ElectionCog(commands.Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
# noinspection PyTypeChecker
|
# noinspection PyTypeChecker
|
||||||
soup = await asyncio.to_thread(BeautifulSoup, response.text)
|
soup = await asyncio.to_thread(BeautifulSoup, response.text, "html.parser")
|
||||||
results = await self.bot.loop.run_in_executor(None, self.process_soup, soup)
|
results = await self.bot.loop.run_in_executor(None, self.process_soup, soup)
|
||||||
if results:
|
if results:
|
||||||
date = ctx.message.created_at.date().strftime("%B %Y")
|
date = ctx.message.created_at.date().strftime("%B %Y")
|
||||||
|
|
Loading…
Reference in a new issue