传输类型为 "multipart/form-data" 的传送写法 (上传文件 和图片)
一: 传字符的情况:
抓包数据:
传输的数据:
python-request写法:
二:上传图片的情况:
疑惑
这种请求怎么模拟
解答:
files={
'token':(None,'Q5-5r0UN6FS5CfX-5Uqhmb8ltx6bt98RVTAkn07Y:fPWjte-M0gnvkMHxZZ93cHlaQFQ=:eyJzY29wZSI6InN0YXRpYyIsImRlYWRsaW5lIjoxNTcxNDYzMzIwfQ=='),
"key":(None,'classroom-record/20191019/image/timg_1571459719392.jpg'),
'file':("timg.jpg",open('/Users/lucax/Desktop/timg.jpg','rb'),'image/jpeg')
}
url="https://upload.qiniup.com/"
headers={
# 'Content-Type':'multipart/form-data; boundary=----WebKitFormBoundaryvasHQ8vsa4UIab5L',
'Accept':'*/*',
'Sec-Fetch-Site':'cross-site',
'Referer':'https://dev-ai-manage.codemao.cn/linesManage?seriesId=176&lessonId=1995',
'Accept-Encoding':'gzip, deflate, br'
}
r = requests.post(url,headers=headers,files=files)
参考: https://blog.csdn.net/xuezhangjun0121/article/details/82023320