# 修改後的日誌輸出
def request(flow):
flow.request.headers['User-Agent'] ='MitProxy'
print(flow.request.headers)
# 日誌輸出功能
from mitmproxy import ctx
def request(flow):
flow.request.headers['User-Agent'] = 'MitmProxy'
# info,warn,error會顯示不同的顏色
ctx.log.info(str(flow.request.headers))
ctx.log.warn(str(flow.request.headers))
ctx.log.error(str(flow.request.headers))
# Requests的常用功能(可以輸出請求鏈接,請求頭,請求Cookie,請求Host,請求方法,請求端口等)
from mitmproxy import ctx
def request(flow):
request = flow.request
info = ctx.log.info
info(request.url)
info(str(request.headers))
info(str(request.cookies))
info(request.host)
info(request.method)
info(str(request.port))
info(request.scheme)
# 通過手機端更改url,是的手機的訪問頁面也發生改變
def request(flow):
url = 'https://httpbin.org/get'
flow.request.url = url
# 獲得相應的頭信息,cookies,內容等
from mitmproxy import ctx
def response(flow):
response = flow.response
info = ctx.log.info
info(str(response.status_code))
info(str(response.headers))
info(str(response.cookies))
info(str(response.text))