diff options
author | Aldo Cortesi <aldo@corte.si> | 2016-07-15 16:48:01 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-15 16:48:01 +1200 |
commit | 64e16f5112669a31f86183be640eeee3a47c2961 (patch) | |
tree | 2e8ecc38f022c2b302d5ce67fd282dab45941fd9 /examples/har_extractor.py | |
parent | e051928f26afbc58c01d7854b62f8bfb0d4ed5ee (diff) | |
parent | c7d0850d8f697915b183f4fafd5ede7df2245569 (diff) | |
download | mitmproxy-64e16f5112669a31f86183be640eeee3a47c2961.tar.gz mitmproxy-64e16f5112669a31f86183be640eeee3a47c2961.tar.bz2 mitmproxy-64e16f5112669a31f86183be640eeee3a47c2961.zip |
Merge pull request #1356 from cortesi/script
Scripts to addon
Diffstat (limited to 'examples/har_extractor.py')
-rw-r--r-- | examples/har_extractor.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/har_extractor.py b/examples/har_extractor.py index 2a69b9af..90412ec0 100644 --- a/examples/har_extractor.py +++ b/examples/har_extractor.py @@ -2,7 +2,7 @@ This inline script utilizes harparser.HAR from https://github.com/JustusW/harparser to generate a HAR log object. """ -import mitmproxy +import mitmproxy.ctx import six import sys import pytz @@ -221,9 +221,11 @@ def done(): if context.dump_file == '-': mitmproxy.ctx.log(pprint.pformat(json.loads(json_dump))) elif context.dump_file.endswith('.zhar'): - file(context.dump_file, "w").write(compressed_json_dump) + with open(context.dump_file, "wb") as f: + f.write(compressed_json_dump) else: - file(context.dump_file, "w").write(json_dump) + with open(context.dump_file, "wb") as f: + f.write(json_dump) mitmproxy.ctx.log( "HAR log finished with %s bytes (%s bytes compressed)" % ( len(json_dump), len(compressed_json_dump) |