关于CSDN博客上传图片的接口研究

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chouzhou9701/article/details/89056392

代码实现

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

猜你喜欢

转载自blog.csdn.net/chouzhou9701/article/details/89056392