1.编写上传脚本

import requests
import json
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": "xxx" # 自己的cookie 可以通过F12查看
}

# 类型映射
mimeMapping = {".png": 'image/png', '.gif': 'image/gif', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg'}

for i in argv[1:]:
    # 图片地址参数
    imgPath = i

    # 对应的mime
    mime = imgPath[imgPath.rindex("."):]

    file = [
        ("",("fileName", open(imgPath, "rb"), mimeMapping[mime]))
    ]

    response = requests.post(uploadUrl,headers = headers,files = file)

    data = json.loads(response.text)
    print(data['message'])

2.设置软件

typora自动上传图片到cnblogs

相关文章:

  • 2021-12-09
  • 2021-07-31
  • 2021-04-27
  • 2021-04-05
  • 2021-12-10
  • 2021-12-18
  • 2021-11-17
猜你喜欢
  • 2021-06-14
  • 2021-12-04
  • 2021-05-25
  • 2022-01-13
相关资源
相似解决方案