我正在尝试使用python" request"进行多部分/表单数据发布请求。库请求有效负载是这个
------WebKitFormBoundaryFpBudhNO5RIwvCAv
Content-Disposition: form-data; name="token"
nwcnfie_3c59dc048e8850243be8079a5c7
------WebKitFormBoundaryFpBudhNO5RIwvCAv
Content-Disposition: form-data; name="uid"
3f7316b6fee4de110e0ab5db7ccdd9df9373
------WebKitFormBoundaryFpBudhNO5RIwvCAv
Content-Disposition: form-data; name="terms"
1
------WebKitFormBoundaryFpBudhNO5RIwvCAv
Content-Disposition: form-data; name="movie_title637ee6f6c51cef5a4887c67116bd7375"
this one is the most awesome movie
------WebKitFormBoundaryFpBudhNO5RIwvCAv
Content-Disposition: form-data; name="description637ee6f6c51cef5a4887c67116bd7375"
------WebKitFormBoundaryFpBudhNO5RIwvCAv
Content-Disposition: form-data; name="files[]"; filename="Time Value of Money - YouTube.FLV"
Content-Type: video/x-flv
------WebKitFormBoundaryFpBudhNO5RIwvCAv--
以下是我尝试发布此内容的方式
files = {'files[]': ("filename", open('Time Value of Money - YouTube.FLV', 'rb'))}
upload_payload = {"token":"nwcnfie_"+getUploadToken(user_page.text),"uid":getUID(user_page.text),"terms":"1","movie_title"+getFileNameHash("Time Value of Money - YouTube.FLV"):"This is a really awesome movie","description"+getFileNameHash("Time Value of Money - YouTube.FLV"):"Awesome"}
response = session.post("http://example.com/uploader.php",data=upload_payload,files=files)
这是执行请求的正确方法,尤其是文件部分吗?我没有得到我期待的结果。请帮忙。