parent
849a0217b9
commit
8a1505d769
@ -32,8 +32,8 @@ def remove_plugin(name):
|
|||||||
|
|
||||||
async def download(name):
|
async def download(name):
|
||||||
html = await get(f'{git_source}{name}.py')
|
html = await get(f'{git_source}{name}.py')
|
||||||
with open(f'plugins/{name}.py', mode='wb') as f:
|
with open(f'plugins/{name}.py', mode='w') as f:
|
||||||
f.write(html.content)
|
f.write(html.text)
|
||||||
return f'plugins/{name}.py'
|
return f'plugins/{name}.py'
|
||||||
|
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ async def speedtest(context):
|
|||||||
f"Timestamp: `{result['timestamp']}`"
|
f"Timestamp: `{result['timestamp']}`"
|
||||||
)
|
)
|
||||||
# 开始处理图片
|
# 开始处理图片
|
||||||
data = (await get(f"{result['result']['url']}.png")).content
|
data = (await get(f"{result['result']['url']}.png")).text
|
||||||
with open('speedtest.png', mode='wb') as f:
|
with open('speedtest.png', mode='wb') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
try:
|
try:
|
||||||
@ -273,7 +273,7 @@ async def speedtest(context):
|
|||||||
f"Timestamp: `{result['timestamp']}`"
|
f"Timestamp: `{result['timestamp']}`"
|
||||||
)
|
)
|
||||||
# 开始处理图片
|
# 开始处理图片
|
||||||
data = (await get(result['share'])).content
|
data = (await get(result['share'])).text
|
||||||
with open('speedtest.png', mode='wb') as f:
|
with open('speedtest.png', mode='wb') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
try:
|
try:
|
||||||
|
@ -25,10 +25,10 @@ class AiohttpResp:
|
|||||||
"""
|
"""
|
||||||
重写返回类型。
|
重写返回类型。
|
||||||
"""
|
"""
|
||||||
def __init__(self, text: str, content: bytes, status_code: int):
|
def __init__(self, text: Any, content: bytes, status_code: int):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
text (str): 网页内容
|
text (Any): 网页内容
|
||||||
content (bytes): 文件内容
|
content (bytes): 文件内容
|
||||||
status_code (int): 网页状态码
|
status_code (int): 网页状态码
|
||||||
"""
|
"""
|
||||||
@ -286,7 +286,10 @@ async def request(method: str,
|
|||||||
session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=timeout))
|
session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=timeout))
|
||||||
resp = await session.request(**config_)
|
resp = await session.request(**config_)
|
||||||
# 返回请求
|
# 返回请求
|
||||||
resp_data = await resp.text()
|
try:
|
||||||
|
resp_data = await resp.text()
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
resp_data = await resp.read()
|
||||||
content = await resp.content.read()
|
content = await resp.content.read()
|
||||||
status_code = resp.status
|
status_code = resp.status
|
||||||
await session.close()
|
await session.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user