关于CSDN博客上传图片的接口研究
代码实现
import requests
from requests_toolbelt import MultipartEncoder
import urllib.parse
fields = {
'file':("004.jpg",open('004.jpg','rb'),"image/jpeg"), #这里上传的图片是 004.jpg
}
m = MultipartEncoder(fields, boundary='------WebKitFormBoundarynTBa3OWoSMrcVf0F')
headers = {
'cookie': '', #填写自己登录博客的cookie
'content-Type': m.content_type,
}
url = 'https://mp.csdn.net/UploadImage?shuiyin=2'
res = requests.post(url, headers=headers, data=m, verify=False)
print(res.json())
这个是我通过抓包获取的csdn博客
上传图片的接口,需要个人用户登录,需要cookie
本文来自博客园,作者:Hello_wshuo,转载请注明原文链接:https://www.cnblogs.com/Hellowshuo/p/15622259.html