mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
17 lines
653 B
Python
17 lines
653 B
Python
|
|
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
|