其他分享
首页 > 其他分享> > 博客园做Typora的图床

博客园做Typora的图床

作者:互联网

新建一个py文件

import requests
from sys import argv

uploadUrl = 'https://upload.cnblogs.com/imageuploader/processupload?host=www.cnblogs.com'

headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
    "cookie":  "" # 这里的内容要自己填写
}

for i in argv[1:]:
    format = i[i.rfind(".") + 1:]
    file = [
        ("", ("fileName", open(i, "rb"), "image/" + format))
    ]
    response = requests.post(uploadUrl, headers=headers, files=file)

    text = response.text
    imgUrl = text[text.find("https"):-2]

    print(imgUrl) 

获得Cookie

访问自己的网站

image-20220823001758565

Typora设置

写上python 文件地址即可,记得验证一下

image-20220823001900713

标签:format,text,博客园,Typora,537.36,headers,图床,file
来源: https://www.cnblogs.com/cyfuture/p/16614736.html