mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-22 19:47:56 +08:00
add example to show how to read mitmproxy dump files, refs #207
This commit is contained in:
17
examples/read_dumpfile.py
Normal file
17
examples/read_dumpfile.py
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Simple script showing how to read a mitmproxy dump file
|
||||
#
|
||||
|
||||
from libmproxy import flow
|
||||
import json, sys
|
||||
|
||||
with open("logfile", "rb") as f:
|
||||
freader = flow.FlowReader(f)
|
||||
try:
|
||||
for i in freader.stream():
|
||||
print i.request.host
|
||||
json.dump(i._get_state(), sys.stdout, indent=4)
|
||||
print ""
|
||||
except flow.FlowReadError, v:
|
||||
print "Flow file corrupted. Stopped loading."
|
||||
Reference in New Issue
Block a user