mitmproxy/examples/read_dumpfile

21 lines
507 B
Plaintext
Raw Normal View History

#!/usr/bin/env python
#
# Simple script showing how to read a mitmproxy dump file
#
from mitmproxy import flow
import pprint
2015-05-30 00:03:28 +00:00
import sys
2015-08-16 23:29:24 +00:00
with open(sys.argv[1], "rb") as logfile:
2014-09-08 14:02:31 +00:00
freader = flow.FlowReader(logfile)
pp = pprint.PrettyPrinter(indent=4)
try:
2014-09-08 14:02:31 +00:00
for f in freader.stream():
print(f)
print(f.request.host)
pp.pprint(f.get_state())
print("")
2015-05-30 00:03:28 +00:00
except flow.FlowReadError as v:
2016-04-14 05:34:28 +00:00
print("Flow file corrupted. Stopped loading.")