Created
January 5, 2023 16:11
-
-
Save TomoeMami/9c643fd227402a7d88e823fffe117108 to your computer and use it in GitHub Desktop.
post_sda_dev_pic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def post_pics(imgurl): | |
url = 'https://p.sda1.dev/api/v1/upload_external_noform' | |
async with aiohttp.ClientSession(headers=headers) as session: | |
async with session.get(imgurl) as response: | |
data = await response.read() | |
inttime = int(time.time()) | |
pic_suffix = imgurl.split(".")[-1] | |
params={'filename':str(inttime)+'.'+pic_suffix} | |
async with session.post(url,data=data,params=params) as response: | |
resp2 = await response.json() | |
if(resp2['success']): | |
print(imgurl+str(resp2)) | |
rurl = '[img]'+resp2['data']['url']+'[/img]' | |
else: | |
rurl = '⟦尺寸过大图片,请至原链接查看⟧' | |
return rurl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment