Last active
July 28, 2021 22:41
-
-
Save Ze1598/dc94bf74fae999580244dab00ef89b85 to your computer and use it in GitHub Desktop.
Arknights - scrape operator level up stats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import pickle | |
from bs4 import BeautifulSoup | |
req = requests.get("https://gamepress.gg/arknights/tools/interactive-operator-list") | |
soup = BeautifulSoup(req.content, "lxml") | |
# Get all the table cells (<td>) with information about the operators | |
op_list = soup.find_all("td", class_="operator-cell") | |
op_dict = {} | |
for op in op_list: | |
# Get the name and their personal page from these HTML elements | |
name = op.find("div", class_="operator-title").a.text | |
page = "https://gamepress.gg" + \ | |
op.find("div", class_="operator-title").a["href"] | |
# Add the new information to the dictionary | |
op_dict[name] = page | |
# Additional manually discovered alternate form operators | |
op_dict["Amiya (Guard)"] = "https://gamepress.gg/arknights/operator/amiya-guard" | |
# Write this dictionary to a pickle file | |
with open("operator_pages.pickle", "wb") as f: | |
pickle.dump(op_dict, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment