From 4ca5324f69dfc67f6ef64ea56a6417597c1747f0 Mon Sep 17 00:00:00 2001 From: Twisuki Date: Tue, 10 Dec 2024 00:30:13 +0800 Subject: [PATCH 1/5] new file: nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py new file: nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Info.py new file: nonebot_plugin_marshoai/tools/marshoai-meogirl/tools.json --- .../tools/marshoai-meogirl/__init__.py | 4 ++++ .../tools/marshoai-meogirl/mg_Info.py | 4 ++++ .../tools/marshoai-meogirl/tools.json | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py create mode 100644 nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Info.py create mode 100644 nonebot_plugin_marshoai/tools/marshoai-meogirl/tools.json diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py b/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py new file mode 100644 index 00000000..4db722dd --- /dev/null +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py @@ -0,0 +1,4 @@ +from . import mg_Info + +async def meogirl(): + return mg_Info.meogirl() \ No newline at end of file diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Info.py b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Info.py new file mode 100644 index 00000000..af3257dd --- /dev/null +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Info.py @@ -0,0 +1,4 @@ + +# Meogirl +def meogirl(): + return "Meogirl指的是\"萌娘百科\"(https://zh.moegirl.org.cn/ , 简称\"萌百\"), 是一个\"万物皆可萌的百科全书!\"; 同时, MarshoTools也配有\"Meogirl\"插件, 可调用萌百的api" diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/tools.json b/nonebot_plugin_marshoai/tools/marshoai-meogirl/tools.json new file mode 100644 index 00000000..3a4976a7 --- /dev/null +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/tools.json @@ -0,0 +1,9 @@ +[ + { + "type" : "function", + "function" : { + "name" : "marshoai-meogirl__meogirl", + "description" : "介绍Meogirl" + } + } +] \ No newline at end of file From bb2f59eae9d9988362e63fd426d70ec7d67f3621 Mon Sep 17 00:00:00 2001 From: Twisuki Date: Wed, 11 Dec 2024 00:12:22 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=8E=A5=E5=85=A5=E8=90=8C=E5=A8=98?= =?UTF-8?q?=E7=99=BE=E7=A7=91=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/marshoai-meogirl/__init__.py | 8 +- .../tools/marshoai-meogirl/mg_Search.py | 91 +++++++++++++++++++ .../tools/marshoai-meogirl/tools.json | 23 +++++ 3 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py b/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py index 4db722dd..4ad38666 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py @@ -1,4 +1,10 @@ from . import mg_Info +from . import mg_Search +# meogirl async def meogirl(): - return mg_Info.meogirl() \ No newline at end of file + return mg_Info.meogirl() + +# Search +async def search(msg : str, num : int = 3): + return str(mg_Search.search(msg, num)) \ No newline at end of file diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py new file mode 100644 index 00000000..c8c22c11 --- /dev/null +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py @@ -0,0 +1,91 @@ +from nonebot.log import logger + +import re +import requests +from bs4 import BeautifulSoup + +def search(msg : str, num : int): + logger.info(f"搜索 : \"{msg}\"") + result = "" + + url = "https://mzh.moegirl.org.cn/index.php?search=" + msg + response = requests.get(url) + logger.info(f"连接萌娘百科中, 状态码 : {response.status_code}") + + """ + 萌娘百科搜索页面结构 + div.searchresults # 若无, 证明页面已重定向 + └── p ... + └── ul.mw-search-results # 若无, 证明无搜索结果 + └── li # 一个搜索结果 + └── div.mw-search-result-heading > a # 标题 + └── div.mw-searchresult # 内容 + └── div.mw-search-result-data + └── li ... + └── li ... + """ + if response.status_code == 200: + soup = BeautifulSoup(response.text, 'html.parser') + + # 检测div.searchresults, 是否已重定向 + if soup.find('div', class_='searchresults'): + # 检测ul.mw-search-results, 是否有结果 + if soup.find('ul', class_='mw-search-results'): + ul_tag = soup.select('ul.mw-search-results')[0] + li_tags = ul_tag.select('li') + for li_tag in li_tags: + + div_heading = li_tag.select('div.mw-search-result-heading')[0] + if div_heading: + a_tag = div_heading.select('a')[0] + result += a_tag['title'] + "\n" + logger.info(f"搜索到 : \"{a_tag['title']}\"") + + div_result = li_tag.find('div', class_='searchresult') + if div_result: + content = str(div_result).replace('
', '').replace('
', '') + content = content.replace('', '').replace('', '') + result += content + "\n\n" + + num -= 1 + if num == 0: + break + return result + + # 无ul.mw-search-results, 无结果 + else: + logger.info("无结果") + return "无结果" + + # 无div.searchresults, 重定向 + else: + logger.info(f"\"{msg}\"已被重定向") + num = 0 + + """ + 萌娘百科重定向介绍页面结构 + div#mw-content-text + └── div.mw-parser-output # 介绍页面 + └── .... + └── p ? # 可能存在的空p + └── p # 人物介绍 + └── ... + """ + if soup.find('div', class_='mw-parser-output'): + div = soup.find('div', class_='mw-parser-output') + p_tags = div.select('p') + for p_tag in p_tags: + p = str(p_tag) + p = re.sub(r'<.*?>', '', p) + if p != '': + result += str(p) + "/n" + + num += 1 + if num >= 5: + break + return result + + # 状态码非200 + else: + logger.error(f"网络错误, 状态码 : {response.status_code}") + return f"网络错误, 状态码 : {response.status_code}" diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/tools.json b/nonebot_plugin_marshoai/tools/marshoai-meogirl/tools.json index 3a4976a7..94e8596d 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-meogirl/tools.json +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/tools.json @@ -5,5 +5,28 @@ "name" : "marshoai-meogirl__meogirl", "description" : "介绍Meogirl" } + }, + { + "type" : "function", + "function" : { + "name" : "marshoai-meogirl__search", + "description" : "在萌娘百科中搜索(仅用户指定在萌娘百科中搜索才调用此函数)", + "parameters" : { + "type" : "object", + "properties" : { + "msg" : { + "type": "string", + "description": "搜索关键词" + }, + "num" : { + "type": "integer", + "description": "数据显示条数, 默认3, 可留空" + } + } + }, + "required": [ + "msg" + ] + } } ] \ No newline at end of file From ccb12f0f637319070cf066c53ad46c78ca9d62f7 Mon Sep 17 00:00:00 2001 From: Twisuki Date: Wed, 11 Dec 2024 01:50:06 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=94=B9=E6=88=90=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E4=BA=86,=20=E6=94=B9=E5=AE=8C=E5=BD=BB=E5=BA=95=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E7=94=A8=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/marshoai-meogirl/__init__.py | 2 +- .../tools/marshoai-meogirl/mg_Search.py | 155 +++++++++--------- 2 files changed, 81 insertions(+), 76 deletions(-) diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py b/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py index 4ad38666..1e9b5526 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/__init__.py @@ -7,4 +7,4 @@ async def meogirl(): # Search async def search(msg : str, num : int = 3): - return str(mg_Search.search(msg, num)) \ No newline at end of file + return str(await mg_Search.search(msg, num)) diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py index c8c22c11..27f6f637 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py @@ -1,91 +1,96 @@ from nonebot.log import logger import re -import requests +import httpx from bs4 import BeautifulSoup -def search(msg : str, num : int): +async def search(msg : str, num : int): logger.info(f"搜索 : \"{msg}\"") result = "" + headers = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36' + } url = "https://mzh.moegirl.org.cn/index.php?search=" + msg - response = requests.get(url) - logger.info(f"连接萌娘百科中, 状态码 : {response.status_code}") + async with httpx.AsyncClient() as client: + response = await client.get(url, headers = headers) + logger.info(response.headers.get('Location')) + logger.info(f"连接萌娘百科中, 状态码 : {response.status_code}") - """ - 萌娘百科搜索页面结构 - div.searchresults # 若无, 证明页面已重定向 - └── p ... - └── ul.mw-search-results # 若无, 证明无搜索结果 - └── li # 一个搜索结果 - └── div.mw-search-result-heading > a # 标题 - └── div.mw-searchresult # 内容 - └── div.mw-search-result-data - └── li ... - └── li ... - """ - if response.status_code == 200: - soup = BeautifulSoup(response.text, 'html.parser') + """ + 萌娘百科搜索页面结构 + div.searchresults # 若无, 证明页面已重定向 + └── p ... + └── ul.mw-search-results # 若无, 证明无搜索结果 + └── li # 一个搜索结果 + └── div.mw-search-result-heading > a # 标题 + └── div.mw-searchresult # 内容 + └── div.mw-search-result-data + └── li ... + └── li ... + """ + if response.status_code == 200: + soup = BeautifulSoup(response.text, 'html.parser') - # 检测div.searchresults, 是否已重定向 - if soup.find('div', class_='searchresults'): - # 检测ul.mw-search-results, 是否有结果 - if soup.find('ul', class_='mw-search-results'): - ul_tag = soup.select('ul.mw-search-results')[0] - li_tags = ul_tag.select('li') - for li_tag in li_tags: + # 检测div.searchresults, 是否已重定向 + if soup.find('div', class_='searchresults'): + # 检测ul.mw-search-results, 是否有结果 + if soup.find('ul', class_='mw-search-results'): + ul_tag = soup.select('ul.mw-search-results')[0] + li_tags = ul_tag.select('li') + for li_tag in li_tags: - div_heading = li_tag.select('div.mw-search-result-heading')[0] - if div_heading: - a_tag = div_heading.select('a')[0] - result += a_tag['title'] + "\n" - logger.info(f"搜索到 : \"{a_tag['title']}\"") + div_heading = li_tag.select('div.mw-search-result-heading')[0] + if div_heading: + a_tag = div_heading.select('a')[0] + result += a_tag['title'] + "\n" + logger.info(f"搜索到 : \"{a_tag['title']}\"") - div_result = li_tag.find('div', class_='searchresult') - if div_result: - content = str(div_result).replace('
', '').replace('
', '') - content = content.replace('', '').replace('', '') - result += content + "\n\n" + div_result = li_tag.find('div', class_='searchresult') + if div_result: + content = str(div_result).replace('
', '').replace('
', '') + content = content.replace('', '').replace('', '') + result += content + "\n\n" - num -= 1 - if num == 0: - break - return result - - # 无ul.mw-search-results, 无结果 - else: - logger.info("无结果") - return "无结果" - - # 无div.searchresults, 重定向 - else: - logger.info(f"\"{msg}\"已被重定向") - num = 0 - - """ - 萌娘百科重定向介绍页面结构 - div#mw-content-text - └── div.mw-parser-output # 介绍页面 - └── .... - └── p ? # 可能存在的空p - └── p # 人物介绍 - └── ... - """ - if soup.find('div', class_='mw-parser-output'): - div = soup.find('div', class_='mw-parser-output') - p_tags = div.select('p') - for p_tag in p_tags: - p = str(p_tag) - p = re.sub(r'<.*?>', '', p) - if p != '': - result += str(p) + "/n" - - num += 1 - if num >= 5: + num -= 1 + if num == 0: break - return result + return result - # 状态码非200 - else: - logger.error(f"网络错误, 状态码 : {response.status_code}") - return f"网络错误, 状态码 : {response.status_code}" + # 无ul.mw-search-results, 无结果 + else: + logger.info("无结果") + return "无结果" + + # 无div.searchresults, 重定向 + else: + logger.info(f"\"{msg}\"已被重定向") + num = 0 + + """ + 萌娘百科重定向介绍页面结构 + div#mw-content-text + └── div.mw-parser-output # 介绍页面 + └── .... + └── p ? # 可能存在的空p + └── p # 人物介绍 + └── ... + """ + if soup.find('div', class_='mw-parser-output'): + div = soup.find('div', class_='mw-parser-output') + p_tags = div.select('p') + for p_tag in p_tags: + p = str(p_tag) + p = re.sub(r'<.*?>', '', p) + if p != '': + result += str(p) + "/n" + + num += 1 + if num >= 5: + break + return result + + # 状态码非200 + else: + logger.error(f"网络错误, 状态码 : {response.status_code}") + return f"网络错误, 状态码 : {response.status_code}" From 086f21272f5e5617ba0d1d5461582f61205e6fc6 Mon Sep 17 00:00:00 2001 From: Twisuki Date: Wed, 11 Dec 2024 18:09:08 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9,=20=E4=BD=86=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=85=A8=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/marshoai-meogirl/mg_Search.py | 148 ++++++++++-------- 1 file changed, 80 insertions(+), 68 deletions(-) diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py index 27f6f637..2e54522d 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py @@ -2,24 +2,34 @@ from nonebot.log import logger import re import httpx +import urllib.parse from bs4 import BeautifulSoup +from watchfiles import awatch + + +async def get_async_data (url): + async with httpx.AsyncClient() as client: + return await client.get(url) async def search(msg : str, num : int): logger.info(f"搜索 : \"{msg}\"") result = "" - headers = { - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36' - } - url = "https://mzh.moegirl.org.cn/index.php?search=" + msg - async with httpx.AsyncClient() as client: - response = await client.get(url, headers = headers) - logger.info(response.headers.get('Location')) - logger.info(f"连接萌娘百科中, 状态码 : {response.status_code}") + # headers = { + # 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36' + # } + url = "https://mzh.moegirl.org.cn/index.php?search=" + urllib.parse.quote_plus(msg) + # client = httpx.AsyncClient() + # async with client: + # response = await client.post(url, headers = headers) + response = await get_async_data(url) + logger.info(f"连接\"{response.headers.get('location')}\"中, 状态码 : {response.status_code}") + # 正常搜索 + if response.status_code == 200: """ 萌娘百科搜索页面结构 - div.searchresults # 若无, 证明页面已重定向 + div.searchresults └── p ... └── ul.mw-search-results # 若无, 证明无搜索结果 └── li # 一个搜索结果 @@ -29,68 +39,70 @@ async def search(msg : str, num : int): └── li ... └── li ... """ - if response.status_code == 200: - soup = BeautifulSoup(response.text, 'html.parser') + soup = BeautifulSoup(response.text, 'html.parser') - # 检测div.searchresults, 是否已重定向 - if soup.find('div', class_='searchresults'): - # 检测ul.mw-search-results, 是否有结果 - if soup.find('ul', class_='mw-search-results'): - ul_tag = soup.select('ul.mw-search-results')[0] - li_tags = ul_tag.select('li') - for li_tag in li_tags: + # 检测ul.mw-search-results, 是否有结果 + if soup.find('ul', class_='mw-search-results'): + ul_tag = soup.select('ul.mw-search-results')[0] + li_tags = ul_tag.select('li') + for li_tag in li_tags: - div_heading = li_tag.select('div.mw-search-result-heading')[0] - if div_heading: - a_tag = div_heading.select('a')[0] - result += a_tag['title'] + "\n" - logger.info(f"搜索到 : \"{a_tag['title']}\"") + div_heading = li_tag.select('div.mw-search-result-heading')[0] + if div_heading: + a_tag = div_heading.select('a')[0] + result += a_tag['title'] + "\n" + logger.info(f"搜索到 : \"{a_tag['title']}\"") - div_result = li_tag.find('div', class_='searchresult') - if div_result: - content = str(div_result).replace('
', '').replace('
', '') - content = content.replace('', '').replace('', '') - result += content + "\n\n" + div_result = li_tag.find('div', class_='searchresult') + if div_result: + content = str(div_result).replace('
', '').replace('
', '') + content = content.replace('', '').replace('', '') + result += content + "\n\n" - num -= 1 - if num == 0: - break - return result + num -= 1 + if num == 0: + break + return result - # 无ul.mw-search-results, 无结果 - else: - logger.info("无结果") - return "无结果" - - # 无div.searchresults, 重定向 - else: - logger.info(f"\"{msg}\"已被重定向") - num = 0 - - """ - 萌娘百科重定向介绍页面结构 - div#mw-content-text - └── div.mw-parser-output # 介绍页面 - └── .... - └── p ? # 可能存在的空p - └── p # 人物介绍 - └── ... - """ - if soup.find('div', class_='mw-parser-output'): - div = soup.find('div', class_='mw-parser-output') - p_tags = div.select('p') - for p_tag in p_tags: - p = str(p_tag) - p = re.sub(r'<.*?>', '', p) - if p != '': - result += str(p) + "/n" - - num += 1 - if num >= 5: - break - return result - - # 状态码非200 + # 无ul.mw-search-results, 无结果 else: - logger.error(f"网络错误, 状态码 : {response.status_code}") - return f"网络错误, 状态码 : {response.status_code}" + logger.info("无结果") + return "无结果" + + # 重定向 + elif response.status_code == 302: + logger.info(f"\"{msg}\"已被重定向") + # 读取重定向结果 + soup = BeautifulSoup(response.text, 'html.parser') + logger.success("重定向成功") + logger.info(response) + num = 0 + + """ + 萌娘百科重定向介绍页面结构 + div#mw-content-text + └── div.mw-parser-output # 介绍页面 + └── .... + └── p ? # 可能存在的空p + └── p # 人物介绍 + └── ... + """ + if soup.find('div', class_='mw-parser-output'): + div = soup.find('div', class_='mw-parser-output') + p_tags = div.select('p') + for p_tag in p_tags: + p = str(p_tag) + p = re.sub(r'<.*?>', '', p) + if p != '': + result += str(p) + "\n" + + num += 1 + if num >= 5: + break + return result + + # 状态码非200或302 + else: + logger.error(f"网络错误, 状态码 : {response.status_code}") + return f"网络错误, 状态码 : {response.status_code}" + From 2aba05d9ae5de0ad58d53e9eead8aec11181f17f Mon Sep 17 00:00:00 2001 From: Twisuki Date: Wed, 11 Dec 2024 18:37:36 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/marshoai-meogirl/mg_Search.py | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py index 2e54522d..d7726f09 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py @@ -4,26 +4,22 @@ import re import httpx import urllib.parse from bs4 import BeautifulSoup -from watchfiles import awatch +headers = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36' +} async def get_async_data (url): - async with httpx.AsyncClient() as client: - return await client.get(url) + async with httpx.AsyncClient(timeout = None) as client: + return await client.get(url, headers = headers) async def search(msg : str, num : int): logger.info(f"搜索 : \"{msg}\"") result = "" - # headers = { - # 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36' - # } url = "https://mzh.moegirl.org.cn/index.php?search=" + urllib.parse.quote_plus(msg) - # client = httpx.AsyncClient() - # async with client: - # response = await client.post(url, headers = headers) response = await get_async_data(url) - logger.info(f"连接\"{response.headers.get('location')}\"中, 状态码 : {response.status_code}") + logger.success(f"连接{url}完成, 状态码 : {response.status_code}") # 正常搜索 if response.status_code == 200: @@ -71,11 +67,11 @@ async def search(msg : str, num : int): # 重定向 elif response.status_code == 302: - logger.info(f"\"{msg}\"已被重定向") + logger.info(f"\"{msg}\"已被重定向至\"{response.headers.get('location')}\"") # 读取重定向结果 + response = await get_async_data(response.headers.get('location')) soup = BeautifulSoup(response.text, 'html.parser') logger.success("重定向成功") - logger.info(response) num = 0 """ @@ -94,7 +90,7 @@ async def search(msg : str, num : int): p = str(p_tag) p = re.sub(r'<.*?>', '', p) if p != '': - result += str(p) + "\n" + result += str(p) num += 1 if num >= 5: @@ -105,4 +101,3 @@ async def search(msg : str, num : int): else: logger.error(f"网络错误, 状态码 : {response.status_code}") return f"网络错误, 状态码 : {response.status_code}" -