-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScraper.py
More file actions
69 lines (58 loc) · 1.98 KB
/
Scraper.py
File metadata and controls
69 lines (58 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import requests
import pandas as pd
# Download JSON
url = "https://raw.githubusercontent.com/Aceship/AN-EN-Tags/master/json/gamedata/en_US/gamedata/excel/character_table.json"
data = requests.get(url).json()
# Prepare storage
rows = {
"name": [],
"unit_classes": [],
"sub_classes": [],
"hp": [],
"atk": [],
"def": [],
"res": [],
"rdp": [],
"cost": [],
"blk": [],
"spe": []
}
for char_id, char in data.items():
# Skip limited/unobtainable
if char.get("isNotObtainable", False):
continue
unit_class = char.get("profession", "")
sub_class = char.get("subProfessionId", "")
# Skip invalid sub_class or token operators
if sub_class in ["notchar1", "notchar2"] or unit_class == "TOKEN":
continue
# Optional: keep only advanced operators (rarity >= 3)
if char.get("rarity", 0) < 3:
continue
rows["name"].append(char["name"])
rows["unit_classes"].append(unit_class)
rows["sub_classes"].append(sub_class)
# Take last phase stats (usually max level)
phases = char.get("phases", [])
if not phases:
continue # skip characters with no phases
last_phase = phases[-1]
keyframes = last_phase.get("attributesKeyFrames", [])
if not keyframes:
continue
stats = keyframes[-1].get("data", {})
# Convert numeric stats explicitly
rows["hp"].append(int(stats.get("maxHp", 0)))
rows["atk"].append(int(stats.get("atk", 0)))
rows["def"].append(int(stats.get("def", 0)))
rows["res"].append(float(stats.get("magicResistance", 0)))
rows["rdp"].append(int(stats.get("respawnTime", 0)))
rows["cost"].append(int(stats.get("cost", 0)))
rows["blk"].append(int(stats.get("blockCnt", 0)))
rows["spe"].append(float(stats.get("baseAttackTime", 0.0)))
# Build DataFrame
df = pd.DataFrame(rows)
df = df.set_index("name") # optional: set name as index
# Save CSV
df.to_csv("Database.csv", index=True)
print("Database.csv created with", len(df), "operators")