How can I save all requests/responses to a file?

Hi.

I’m looking at an encrypted connection and want to save decrypted data in “time|request|response” format.
Like going into each request and pressing P in mitmproxy. What is the easiest way to do this?

OK, this script seems to be working.
The site has some outdated examples though o.O

`import random
import sys

from mitmproxy.models import decoded
import time

def start(context, argv):
context.folder = argv[1]

def response(context, flow):
t = time.time()*1000
f = open("%s/%d.request" % (context.folder,t), “wb”)
with decoded(flow.request):
f.write(flow.request.content)

f = open("%s/%d.response" % (context.folder,t), "wb")
with decoded(flow.response):
    f.write(flow.response.content)

`

Thanks for updating your question with an answer yourself :slight_smile:

Which site and where?

Github. While I was browsing examples and reading docs I noticed that some of the examples seemed to be outdated comparing to docs. Don’t remember which ones already/.

Thanks. You most likely browsed the examples on the master branch, which work on master but not on 0.17.