From 48b5b754b1032a29f724eca500762191ef08f341 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 14 Nov 2023 23:53:31 +0800 Subject: [PATCH] fix: station image cdn --- res_func/avatar.py | 12 +++--------- res_func/light_cone.py | 6 ++++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/res_func/avatar.py b/res_func/avatar.py index 0265432..f26ecef 100644 --- a/res_func/avatar.py +++ b/res_func/avatar.py @@ -44,18 +44,12 @@ async def parse_station(datas, name: str, tag: Tag, cid: int): def get_third_pic(): _tag = tag.find("div", {"class": "a69d1"}) style = _tag.get("style") - return f'{base_station_url}/{style[style.find("(") + 2:style.find(")")]}' + return f'{style[style.find("(") + 1:style.find(")")]}' third_pic = get_third_pic() 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")}' - ) + four_pic = f'{text[text.find("(") + 2:text.find(")") - 1]}' if text else "" + first_pic = f'{soup.find("img", {"class": "ac39b a6602"}).get("src")}' datas.append( AvatarIcon( id=cid, diff --git a/res_func/light_cone.py b/res_func/light_cone.py index c36988e..56290e9 100644 --- a/res_func/light_cone.py +++ b/res_func/light_cone.py @@ -15,8 +15,10 @@ async def parse_station(icon: LightConeIcon, tag: Tag): html = await client.get(f'{base_station_url}{tag.get("href")}') soup = BeautifulSoup(html.text, "lxml") - first_pic = f'{base_station_url}{soup.find("img", {"class": "standard-icon a6602"}).get("src")}' - second_pic = f'{base_station_url}{soup.find("img", {"class": "a2b16 mobile-only-elem ab8c3"}).get("src")}' + first_pic = f'{soup.find("img", {"class": "standard-icon a6602"}).get("src")}' + second_pic = ( + f'{soup.find("img", {"class": "a2b16 mobile-only-elem ab8c3"}).get("src")}' + ) icon.icon = [first_pic, second_pic] if light_cone_model := all_light_cones_map.get(icon.id): icon.name = light_cone_model.name