先抓包格式化headers,然后查看form-data传的字段名
注意headers中的 content-type必须去掉!!!!
import requests
headers = {'Pragma': 'no-cache', 'Cache-Control': 'no-cache',
'X-USER-TOKEN': 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMCIsInVzZXJOYW1lIjoiSFgwMDEyMTM4IiwiZXhwIjoxNTY2Mzg3ODA1LCJ1c2VySWQiOiIyMCIsImlhdCI6MTU2NjM3MzQwNX0.9w__2RGncpdMvbiQAmk75ThgPwDaTXF1VyY1xKVs_zFduUEoJ3_6X2q3ZVYsFIpChKeLEWelhwlmMxEP4lU9QA',
'Origin': 'http://xx.cn',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36',
'Accept': '*/*',
# 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundarycDnnz7eKalCPv6GJ',
'Referer': 'http://xx.cn/manager/', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8'}
url = 'http://xx.cn/loan-manager-front/upload'
files = {'attach': ('p5.png', open('../p5.png', 'rb'))}
r= requests.post(url, headers=headers, files=files)
print(requests.Request('POST', url, headers=headers, files=files).prepare().body.decode(
'ascii')) # 打印字段名和类型
print(r.text)