mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-02-12 15:39:58 +08:00
改成异步了, 改完彻底不能用了
This commit is contained in:
parent
bb2f59eae9
commit
ccb12f0f63
@ -7,4 +7,4 @@ async def meogirl():
|
|||||||
|
|
||||||
# Search
|
# Search
|
||||||
async def search(msg : str, num : int = 3):
|
async def search(msg : str, num : int = 3):
|
||||||
return str(mg_Search.search(msg, num))
|
return str(await mg_Search.search(msg, num))
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import requests
|
import httpx
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
def search(msg : str, num : int):
|
async def search(msg : str, num : int):
|
||||||
logger.info(f"搜索 : \"{msg}\"")
|
logger.info(f"搜索 : \"{msg}\"")
|
||||||
result = ""
|
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
|
url = "https://mzh.moegirl.org.cn/index.php?search=" + msg
|
||||||
response = requests.get(url)
|
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}")
|
logger.info(f"连接萌娘百科中, 状态码 : {response.status_code}")
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user