From 6aaf45985aa2c61dbb57918bb3275d84f949b45d Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 6 Jun 2023 23:04:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20new=20relics=20style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res_func/avatar.py | 14 ++++++++------ res_func/relic_res.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/res_func/avatar.py b/res_func/avatar.py index 74ebe82..71e2a90 100644 --- a/res_func/avatar.py +++ b/res_func/avatar.py @@ -1,4 +1,5 @@ import asyncio +import re from pathlib import Path from typing import Dict, List @@ -29,14 +30,17 @@ async def fetch_config(text_map_data: Dict[str, str]) -> List[AvatarConfig]: async def parse_station(datas, name: str, tag: Tag, cid: int): + html = await client.get(f'{base_station_url}{tag.get("href")}') + if not cid: + reg = r'skillTreePoints":\[{"id":(\d+),' + cid = int(re.findall(reg, html.text)[0][:-3]) + soup = BeautifulSoup(html.text, "lxml") second_pic = "" if avatar_model := all_avatars_map.get(cid): second_pic = avatar_model.icon elif avatar_model := all_avatars_name.get(name): second_pic = avatar_model.icon third_pic = f'{base_station_url}{tag.find("img").get("src")}' - html = await client.get(f'{base_station_url}{tag.get("href")}') - soup = BeautifulSoup(html.text, "lxml") text = soup.find("div", {"class": "a6678 a4af5"}).get("style") four_pic = f'{base_station_url}{text[text.find("(") + 2:text.find(")") - 1]}' if text else "" first_pic = f'{base_station_url}{soup.find("img", {"class": "ac39b a6602"}).get("src")}' @@ -81,10 +85,8 @@ async def fetch_station(configs_map: Dict[str, AvatarConfig]) -> List[AvatarIcon if name == "开拓者": player_avatars.append(avatar) continue - if avatar_model := configs_map.get(name): - tasks.append(parse_station(datas, name, avatar, avatar_model.AvatarID)) - else: - print(f"未找到角色 {name} 的数据") + avatar_model = configs_map.get(name) + tasks.append(parse_station(datas, name, avatar, avatar_model.AvatarID if avatar_model else None)) await fetch_station_ktz(tasks, datas, player_avatars) await asyncio.gather(*tasks) return datas diff --git a/res_func/relic_res.py b/res_func/relic_res.py index 98d6200..702dffe 100644 --- a/res_func/relic_res.py +++ b/res_func/relic_res.py @@ -14,7 +14,7 @@ async def fix_set_image(): await read_relics(relics_path) req = await client.get(relic_url) soup = BeautifulSoup(req.text, "lxml") - divs = soup.find_all("a", {"class": "aff5a ae026 a2a45"}) + divs = soup.find_all("a", {"class": "aff5a"}) data_map: Dict[int, Tuple[str, List[str]]] = {} for div in divs: sid = int(div.get("href").split("/")[-1])