如何使用 Python 在 Mitmproxy 上打印响应内容
How to print response content on Mitmproxy using Python
我试过运行这样的代码:
def request(flow: http.HTTPFlow) -> None:
if("..." in flow.request.url):
print(flow.response.content)
但我总是得到错误:AttributeError: 'NoneType' object has no attribute 'content'
我不知道如何正确检索响应内容。有人可以帮助我吗?谢谢
您正试图在 request
挂钩中访问 flow.response
。 request
钩子在 mitmproxy 将请求发送到目标服务器之前触发,因此您显然还没有响应。这里的简单解决方法是使用 def response(...): ...
.
我试过运行这样的代码:
def request(flow: http.HTTPFlow) -> None:
if("..." in flow.request.url):
print(flow.response.content)
但我总是得到错误:AttributeError: 'NoneType' object has no attribute 'content'
我不知道如何正确检索响应内容。有人可以帮助我吗?谢谢
您正试图在 request
挂钩中访问 flow.response
。 request
钩子在 mitmproxy 将请求发送到目标服务器之前触发,因此您显然还没有响应。这里的简单解决方法是使用 def response(...): ...
.