1、模板maplocal.py格式
from mitmproxy import http
def request(flow: http.HTTPFlow) -> None:
if flow.request.pretty_url == "https://www.baidu.com/":
flow.response = http.HTTPResponse.make(
200,
b"Hello World",
{"Content-Type": "text/html"}
2、在maplocal.py路径下执行启动文件
H:\git\python\untitled\mitmproxy>mitmdump -p 8888 -s ./maplocal.py
Loading script ./maplocal.py
Proxy server listening at http://*:8888
127.0.0.1:54810: GET https://www.baidu.com/
<< 200 OK 11b
127.0.0.1:54810: GET https://www.baidu.com/favicon.ico
<< 200 OK 1.92k
127.0.0.1:54810: GET https://www.baidu.com/
<< 200 OK 11b
127.0.0.1:54810: GET https://www.baidu.com/favicon.ico
<< 200 OK 1.92k
127.0.0.1:54810: GET https://www.baidu.com/
<< 200 OK 11b
127.0.0.1:54810: GET https://www.baidu.com/favicon.ico
执行结果
|