mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-30 09:10:01 +08:00
update alapi
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import aiohttp
|
||||
from util.utils import get_local_proxy
|
||||
|
||||
|
||||
async def get_data(url: str, params: dict):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
try:
|
||||
async with session.get(url, proxy=get_local_proxy(), timeout=2, params=params) as response:
|
||||
data = await response.json()
|
||||
if data['code'] == 200:
|
||||
if not data['data']:
|
||||
return '没有搜索到...', 997
|
||||
return data, 200
|
||||
else:
|
||||
return f'发生了错误...code:{data["code"]}', 999
|
||||
except TimeoutError:
|
||||
return '超时了....', 998
|
||||
Reference in New Issue
Block a user