Skip to content

Instantly share code, notes, and snippets.

@ZOI-dayo
Last active July 3, 2023 09:41
Show Gist options
  • Save ZOI-dayo/5ffe8f6e62ea7c58d074953192ac50bf to your computer and use it in GitHub Desktop.
Save ZOI-dayo/5ffe8f6e62ea7c58d074953192ac50bf to your computer and use it in GitHub Desktop.
AJL Grapher
import requests
from bs4 import BeautifulSoup
import matplotlib.pyplot as plt
import numpy as np
url = "https://img.atcoder.jp/ajl2023/output_personal_grade6.html"
response = requests.get(url)
response.encoding = response.apparent_encoding
soup = BeautifulSoup(response.text, "html.parser")
table = soup.find("table", {"class": "table_wrap"})
rows = table.findAll("tr")
# fig = plt.figure(figsize=(6, 4), dpi=72)
fig, ax = plt.subplots()
select = [
"okkuu2",
"anmichi",
"AItale",
# "Taiki0715",
# "alcea",
# "MZKi",
# "tada72",
"KoD",
# "iro_",
# "syun0713",
# "yuta28",
# "ku_senjan",
# "TwoSquirrels",
# "shiborimame",
"iwannadie",
# "kaerusan82433413",
# "2bit",
# "CaNaRiA7",
"ZOIZOI",
# "tharuto",
# "shunki1",
# "sorachandu",
# "ozraru",
# "hotep",
# "Skyo",
"Zoi2"
]
for row in rows:
td = row.findAll("td")
if len(td) == 0:
continue
rank = td[0].get_text()
name = td[1].get_text()
# print(name)
if select.count(name) == 0:
continue
color = td[1].find("a").find("b").find("font").attrs["color"]
school = td[2].get_text()
prefecture = td[3].get_text()
grade = td[4].get_text()
score_sum = td[5].get_text()
scores = [int("0" + i.get_text()) for i in td[6:]]
result = []
valuable = []
for s in scores:
if s != 0:
valuable.append(s)
if len(valuable) > 10:
valuable.sort()
valuable.pop(0)
result.append(sum(valuable))
# result = np.log2(result)
plt.plot(result, ls="-", label=name, color=color)
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment