Skip to content

Instantly share code, notes, and snippets.

@TomoeMami
Created January 5, 2023 16:11
Show Gist options
  • Save TomoeMami/9c643fd227402a7d88e823fffe117108 to your computer and use it in GitHub Desktop.
Save TomoeMami/9c643fd227402a7d88e823fffe117108 to your computer and use it in GitHub Desktop.
post_sda_dev_pic
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