一、场景
就是想用python脚本录制相关请求流量,然后回放给服务
二、脚本
import mitmproxy import json class HttpFlowRecorder: def __init__(self): self.traffic = [] def request(self, flow): request_info = { "url": flow.request.url, "method": flow.request.method, "headers": dict(flow.request.headers), "body": flow.request.text, } self.traffic.append(request_info) def response(self, flow): pass def done(self): with open("http_requests.log", "w") as file: file.write(json.dumps(self.traffic)) addons = [ FlowRecorder() ]
三、执行脚本
sudo mitmdump -s traffic.py
四、设置浏览器
1、搜索代理设置
2、打开代理设置
标签:http,request,self,写入,flow,mitmproxy,traffic,def From: https://www.cnblogs.com/fireblackman/p/18315999