diff --git a/src/plugins/zhibo8/plugins/Foresee.py b/src/plugins/zhibo8/plugins/Foresee.py index bf227c6..691f403 100644 --- a/src/plugins/zhibo8/plugins/Foresee.py +++ b/src/plugins/zhibo8/plugins/Foresee.py @@ -17,14 +17,14 @@ xiaobianStr = r""" 小小: """ vsMap = {} - @zhibo8Command.handle() async def handle_first_receive(bot: Bot, event: Event, state: T_State, args= CommandArg()): # 事件预处理,获取对应的赛程数据 + vsMap.clear() session = HTMLSession() - zhibo8Get = session.get("http://www.zhibo8.cc") + zhibo8Get = session.get("https://www.zhibo8.cc/") print(zhibo8Get) - saishiContent = zhibo8Get.html.xpath("//ul/li[starts-with(@id, 'saishi')]") + saishiContent = zhibo8Get.html.xpath("//div[@class='vct-box']/div[@class='_content']/ul/li") # 解析xpath # 解析xpath for item in saishiContent: @@ -47,7 +47,7 @@ async def getRoundNum(event: Event): round = str(event.get_message()) if round.isdigit() == False: await zhibo8Command.reject(prompt="请输入编号(数字)") - if len(vsMap.keys())>int(round): + if len(vsMap.keys())>=int(round): resultStr = "" roudNum = list(vsMap.keys())[int(round)-1] # for roudNum in vsMap: @@ -60,13 +60,14 @@ async def getRoundNum(event: Event): def parserSaishiItem(saishiStr): html = HTML(html=saishiStr) - listItem = html.xpath("//b//text()") - roundNum = listItem[0].split(" ")[0].strip() - homeName = listItem[0].split(" ")[1].strip() - awayName = listItem[-1].strip() - timeStr = html.xpath("//li/@data-time") - time = datetime.strptime(timeStr[0], "%Y-%m-%d %H:%M") - return (roundNum, time.strftime("%m月%d日%H:%M") + " " + homeName + " vs " + awayName) + # listItem = html.xpath("//b//text()") + roundNum = html.xpath("//span[@class='_league']//text()")[0] + homeName = html.xpath("//span[@class='_teams']//text()")[0].strip() + awayName = html.xpath("//span[@class='_teams']//text()")[-1].strip() + timeStr = html.xpath("./li/@data-time")[0] + time = datetime.strptime(timeStr, "%Y-%m-%d %H:%M") + timeTuple = time.timetuple() + return (roundNum, "{}月{}日".format(timeTuple.tm_mon, timeTuple.tm_mday)+time.strftime("%H:%M") + " " + homeName + " vs " + awayName) def getRoundPrompt(roundMap): @@ -76,4 +77,4 @@ def getRoundPrompt(roundMap): print(key) str += "{}: {} \r\n".format(i, key) i = i+1 - return str \ No newline at end of file + return str