import json import re from graia.application import MessageChain from graia.application.message.elements.internal import Image, Plain from core.template import sendMessage from core.utils import get_url async def weekly(kwargs: dict): try: result = json.loads(await get_url( 'https://minecraft.fandom.com/zh/api.php?action=parse&page=Minecraft_Wiki/weekly&prop=text|revid&format=json')) html = result['parse']['text']['*'] text = re.sub(r'

', '\n', html) # 分段 text = re.sub(r'<(.*?)>', '', text, flags=re.DOTALL) # 移除所有 HTML 标签 text = re.sub(r'\n\n\n', '\n\n', text) # 移除不必要的空行 text = re.sub(r'\n*$', '', text) img = re.findall(r'(?<=src=")(.*?)(?=/revision/latest/scale-to-(width|height)-down/\d{3}\?cb=\d{14}?")', html) page = re.findall(r'(?<=