看你好辛苦,帮你做一个上传图片的代码吧,返回信息中就有上传的图片名称。import httpx
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.55',
'Content-Type':'multipart/form-data; boundary=----WebKitFormBoundaryXBU8YckJYyqg4IJ1',
'Cookie':'PHPSESSID=6htchjqr7u8vdf8raqcmia23a1; universion-date=2022-03-21; universion=0310',
'Host':'www.chaojibiaoge.com',
'Origin':'https://www.chaojibiaoge.com',
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Encoding':'gzip, deflate, br',
'Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'Cache-Control':'max-age=0',
'Connection':'keep-alive',
'Content-Length':'435624',
}
url=r'https://www.chaojibiaoge.com/System/TableEdit/saveUploadedFile/istemp/false/modelid/undefined/fieldid/c2/recordid/null/projectid/ktjwa29p/sharekey/7ugvoaya'
#('1.jpg', open('file ', 'rb'), 'image/jpeg')
with open('11111.jpg', 'rb') as i:
img = i.read()
data=MultipartEncoder(
{
'mcssuploadfile[image1]':('11111.jpg',img, 'image/jpeg'),
'filename':"12xx11.jpg"
},
boundary='----WebKitFormBoundaryXBU8YckJYyqg4IJ1'
)
r = requests.post(url=url,headers=headers,data=data, verify=False)
print(r.text)
返回的代码中<input type='text' id='uploadresult' style='display:none' value='ok:image1<=>11111.jpg~2022/03/11111_DGSsJT[small].jpg' /><div class='uploadresult' style='width:auto'><div style='color:green;font-size:12px'>上传成功</div></div>
value中的内容后半段就是文件名 |