首页 > 编程学习 > 博客园做Typora的图床

博客园做Typora的图床

发布时间:2022/8/23 0:27:43

新建一个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

Copyright © 2010-2022 mfbz.cn 版权所有 |关于我们| 联系方式|豫ICP备15888888号