mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
fix: 重载赛马娘卡池失败
This commit is contained in:
parent
ed6b05605c
commit
9c073383ad
@ -331,9 +331,7 @@ class PrettyHandle(BaseHandle[PrettyData]):
|
|||||||
try:
|
try:
|
||||||
title = announcement.xpath("./@title")[0]
|
title = announcement.xpath("./@title")[0]
|
||||||
url = "https://wiki.biligame.com/" + announcement.xpath("./@href")[0]
|
url = "https://wiki.biligame.com/" + announcement.xpath("./@href")[0]
|
||||||
if re.match(r".*?\d{8}$", title) or re.match(
|
if "卡池" in title:
|
||||||
r"^\d{1,2}月\d{1,2}日.*?", title
|
|
||||||
):
|
|
||||||
break
|
break
|
||||||
except IndexError:
|
except IndexError:
|
||||||
continue
|
continue
|
||||||
@ -353,45 +351,42 @@ class PrettyHandle(BaseHandle[PrettyData]):
|
|||||||
up_chars_name = []
|
up_chars_name = []
|
||||||
up_cards = []
|
up_cards = []
|
||||||
up_cards_name = []
|
up_cards_name = []
|
||||||
soup = BeautifulSoup(result, "lxml")
|
dom = etree.HTML(result, etree.HTMLParser())
|
||||||
heads = soup.find_all("span", {"class": "mw-headline"})
|
content = dom.xpath('//*[@id="mw-content-text"]/div/div/div[1]/div')[0]
|
||||||
|
heads = content.xpath("./div")
|
||||||
for head in heads:
|
for head in heads:
|
||||||
if "时间" in head.text or "期间" in head.text:
|
if "时间" in head.find("./img").tail or "期间" in head.find("./img").tail:
|
||||||
time = head.find_next("p").text.split("\n")[0]
|
time = content.xpath("./p")[1].text.split("\n")[0]
|
||||||
if "~" in time:
|
if "~" in time:
|
||||||
start, end = time.split("~")
|
start, end = time.split("~")
|
||||||
start_time = dateparser.parse(start)
|
start_time = dateparser.parse(start)
|
||||||
end_time = dateparser.parse(end)
|
end_time = dateparser.parse(end)
|
||||||
elif "赛马娘" in head.text:
|
elif "赛马娘" in head.find("./img").tail:
|
||||||
char_img = head.find_next("center").find("img")[
|
char_img = content.xpath("./center")[1].find("./a/img").get("src")
|
||||||
"src"
|
lines = content.xpath("./p")[2].xpath("string(.)").split("\n")
|
||||||
]
|
|
||||||
lines = str(head.find_next("p").text).split("\n")
|
|
||||||
chars = [
|
chars = [
|
||||||
line
|
line
|
||||||
for line in lines
|
for line in lines
|
||||||
if "★" in line and "【" in line and "】" in line
|
if "★" in line and "[" in line and "]" in line
|
||||||
]
|
]
|
||||||
for char in set(chars): # list去重
|
for char in set(chars): # list去重
|
||||||
star = char.count("★")
|
star = char.count("★")
|
||||||
name = re.split(r"[【】]", char)[-2].strip()
|
name = re.split("[ ]",char)[-1]
|
||||||
up_chars.append(
|
up_chars.append(
|
||||||
UpChar(name=name, star=star, limited=False, zoom=70)
|
UpChar(name=name, star=star, limited=False, zoom=70)
|
||||||
)
|
)
|
||||||
up_chars_name.append(name)
|
up_chars_name.append(name)
|
||||||
elif "支援卡" in head.text:
|
elif "支援卡" in head.find("./img").tail:
|
||||||
card_img = head.find_next("center").find("img")[
|
card_img = content.xpath("./center")[2].find("./a/img").get("src")
|
||||||
"src"
|
lines = content.xpath("./p")[3].xpath("string(.)").split("\n")
|
||||||
]
|
|
||||||
lines = str(head.find_next("p").text).split("\n")
|
|
||||||
cards = [
|
cards = [
|
||||||
line
|
line
|
||||||
for line in lines
|
for line in lines
|
||||||
if "R" in line and "【" in line and "】" in line
|
if "R" in line and "[" in line and "]" in line
|
||||||
]
|
]
|
||||||
for card in cards:
|
for card in set(cards):
|
||||||
star = 3 if "SSR" in card else 2 if "SR" in card else 1
|
star = 3 if "SSR" in card else 2 if "SR" in card else 1
|
||||||
name = re.split(r"[【】]", card)[-2].strip()
|
name = re.split("[ ]",card)[-1]
|
||||||
up_cards.append(
|
up_cards.append(
|
||||||
UpChar(name=name, star=star, limited=False, zoom=70)
|
UpChar(name=name, star=star, limited=False, zoom=70)
|
||||||
)
|
)
|
||||||
@ -404,7 +399,7 @@ class PrettyHandle(BaseHandle[PrettyData]):
|
|||||||
start_time=start_time,
|
start_time=start_time,
|
||||||
end_time=end_time,
|
end_time=end_time,
|
||||||
up_char=up_chars,
|
up_char=up_chars,
|
||||||
up_name=up_chars_name,
|
up_name=",".join(up_chars_name),
|
||||||
)
|
)
|
||||||
self.UP_CARD = UpEvent(
|
self.UP_CARD = UpEvent(
|
||||||
title=title,
|
title=title,
|
||||||
@ -412,7 +407,7 @@ class PrettyHandle(BaseHandle[PrettyData]):
|
|||||||
start_time=start_time,
|
start_time=start_time,
|
||||||
end_time=end_time,
|
end_time=end_time,
|
||||||
up_char=up_cards,
|
up_char=up_cards,
|
||||||
up_name=up_cards_name,
|
up_name=",".join(up_cards_name),
|
||||||
)
|
)
|
||||||
self.dump_up_char()
|
self.dump_up_char()
|
||||||
logger.info(f"成功获取{self.game_name_cn}当前up信息...当前up池: {title}")
|
logger.info(f"成功获取{self.game_name_cn}当前up信息...当前up池: {title}")
|
||||||
@ -424,10 +419,8 @@ class PrettyHandle(BaseHandle[PrettyData]):
|
|||||||
self.load_up_char()
|
self.load_up_char()
|
||||||
if self.UP_CHAR and self.UP_CARD:
|
if self.UP_CHAR and self.UP_CARD:
|
||||||
return Message(
|
return Message(
|
||||||
Message.template("重载成功!\n当前UP池子:{}{:image}\n当前支援卡池子:{}{:image}").format(
|
Message.template("重载成功!\n当前UP池子:{}\n当前支援卡池子:{}").format(
|
||||||
self.UP_CHAR.up_name,
|
self.UP_CHAR.up_name,
|
||||||
self.UP_CHAR.pool_img,
|
|
||||||
self.UP_CARD.up_name,
|
self.UP_CARD.up_name,
|
||||||
self.UP_CARD.pool_img,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user