当前位置:网站首页>Get webkitformboundary post login

Get webkitformboundary post login

2022-07-07 20:10:00 nongcunqq

Key points post when headers in boundary and data Medium boundary The data should be consistent
'Content-Type': f'multipart/form-data; boundary=----{web_boundary}',

Random generation 16 Bit case letters + Numbers

import requests
import random,string
from requests_toolbelt import MultipartEncoder

fields = {
    
    'file': ('test.png', your_data, "image/png"),
    'file_id': "0"
}
boundary = '----WebKitFormBoundary' \
           + ''.join(random.sample(string.ascii_letters + string.digits, 16))
m = MultipartEncoder(fields=fields, boundary=boundary)

headers = {
    
    "Host": "xxxx",
    "Connection": "keep-alive",
    "Content-Type": m.content_type
}

req = requests.post('https://xxxx/api/upload', headers=headers, data=m)
print(req.text)

Reference resources
https://stackoverflow.com/questions/51349340/recreate-post-request-with-webkitformboundary-using-pythons-requests

原网站

版权声明
本文为[nongcunqq]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071802505240.html