例如:
------WebKitFormBoundaryHqeRA6k14YbNBQoh
Content-Disposition: form-data; name="id"
1
------WebKitFormBoundaryHqeRA6k14YbNBQoh
Content-Disposition: form-data; name="text"
test
------WebKitFormBoundaryHqeRA6k14YbNBQoh
Content-Disposition: form-data; name="button"
提交
------WebKitFormBoundaryHqeRA6k14YbNBQoh--
怎么提取里面的参数值 id=1 text=test button=提交
1
l4mbda 2019-09-17 15:33:33 +08:00
```
from flask import Flask,request app = Flask(__name__) @app.route('/upload', methods=['POST', 'GET']) def upload(): if request.method == 'POST': #print(request.headers) #print(request.form) temp_info = request.form id_field = temp_info['id'] text_field = temp_info['text'] button_field = temp_info['button'] return "OK" ``` 用 flask 的 request 试下。 |
2
arrow8899 2019-09-17 15:37:38 +08:00
web 服务器基本都实现了的,怎么取看你用的那个框架
|
3
cabbage 2019-09-17 22:13:46 +08:00
aiohttp 有简单实现,可以参照这个 https://stackoverflow.com/a/57264428/7378423
另吐槽下 V2EX 回复不能直接 markdown 挺不方便的,楼上 python 缩进全乱了,游标卡尺都救不了 |
4
Loneyer OP @cabbage 我这里用 requests 抓包到了以下数据:
------WebKitFormBoundaryHqeRA6k14YbNBQoh Content-Disposition: form-data; name="id" 1 ------WebKitFormBoundaryHqeRA6k14YbNBQoh Content-Disposition: form-data; name="text" test ------WebKitFormBoundaryHqeRA6k14YbNBQoh Content-Disposition: form-data; name="button" 提交 ------WebKitFormBoundaryHqeRA6k14YbNBQoh-- 解析里面的参数。id=1 text=test button=提示 . |