import mitmproxy.http
class QH(object):
def request(self, flow: mitmproxy.http.HTTPFlow):
# 发出请求之前做的操作
if 'xxx' in flow.request.url:
# flow.request.url请求的url
if 'max_behot_time=0' in flow.request.url:
#拦截到请求的url把url中的page_type=0改为page_type=1再次发出
flow.request.url = flow.request.url.replace('page_type=0','page_type=1')
def response(self, flow: mitmproxy.http.HTTPFlow):
# 返回结果的修改
if 'index_8d' in flow.request.url:
t0 = ''
t1 = ''
# 修改链接flow.request.url的返回结果,并返回
flow.response.text =flow.response.text.replace(t1,t0)
addons = [
QH()
]
启动:
mitmdump -s E:\mondify_response.py