requests
payload
application/xml
使用这种方式上传信息
在网上看到的都是上传json 没找到xml
在浏览器F12 查看 request payload 信息为
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="subject"
2018-07-16 ����һ ��־
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="TD_HTML_EDITOR_CONTENT"
<p>ds</p><p>a</p>
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="ATTACHMENT_0"; filename=""
Content-Type: application/octet-stream
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="ATTACH_NAME"
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="ATTACH_DIR"
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="DISK_ID"
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="ATTACHMENT_1000"; filename=""
Content-Type: application/octet-stream
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="attachment_id_old"
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="attachment_name_old"
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="OP"
1
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="FROM"
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="dia_date"
2018-07-16
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="dia_type"
1
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="to_id"
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="to_name"
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="SMS_REMIND"
on
------WebKitFormBoundaryPb1p9mxAxlGHdGxA
Content-Disposition: form-data; name="SNS_REMIND"
on
------WebKitFormBoundaryPb1p9mxAxlGHdGxA--
把其中的 name 和下面的值 构造成字典 像下面的代码 再上传
import requests
ddict={
'subject':'2018 test',
'TD_HTML_EDITOR_CONTENT':"just text",
'SNS_REMIND':'on',
'SNS_REMIND': 'on',
'to_name':'',
'to_id':'',
'dia_type':'1',
'dia_date':'2018-07-16',
'FROM':'',
'OP':'1',
'attachment_name_old':'',
'attachment_id_old':'',
'DISK_ID':'',
'ATTACH_DIR':'',
'ATTACH_NAME':''
}
def login():
session = requests.session()
login_data={
'UNAME' : 'uname',
'PASSWORD': 'password',
'encode_type' : '1'
}
session.post('http://yourURL',data=login_data)
res = session.post('http://yourURL',data= ddict)
print(res.text)
login()
网友评论