Using har_extractor.py generates ScriptException

When trying to use the har_extractor.py script, I keep getting a ScriptException: No module named ctx error message when running the following command:

./mitmdump -n -r dumpfile -s “har_extractor.py test.har”

I’ve installed the ctx module to see if this resolves the issue, but it does not.

Here is the full output:
$ ./mitmdump -n -r dumpfile -s "har_extractor.py test.har"
mitmdump: Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mitmproxy/flow.py”, line 694, in load_script
s.load()
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mitmproxy/script/script.py”, line 85, in load
sys.exc_info()[2]
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mitmproxy/script/script.py”, line 80, in load
exec (code, self.ns, self.ns)
File “har_extractor.py”, line 5, in
import mitmproxy.ctx
ScriptException: No module named ctx

Is there an additional module that needs to be installed for this to function correctly?

Hi!

It looks like your inline script is from master, but you are using the latest stable release from mitmproxy. Can you please select the right tag on GitHub and try again?

That did the trick. Thanks!