I’m trying to get BeautifulSoup imported into a mitmdump script and am stuck. I’ve verified that b4 is installed in the same python runtime that mitmdump is executing and even tried forcing the path using os.environ[‘PYTHONPATH’] inside the script. doesn’t work.
Fails with this error:
Script error: Traceback (most recent call last): File "script.py", line 9, in <module> from b4 import BeautifulSoup ImportError: No module named 'b4'
import sys from mitmproxy import io import os #import pdb; pdb.set_trace() from b4 import BeautifulSoup class Writer: def __init__(self, path): self.f = open(path, "wb") def response(self, flow): self.f.write( bytes(flow.request.url,'utf-8')) soup = BeautifulSoup(flow.response.content, 'html.parser') self.f.write( flow.response.content ) def start(): return Writer("out")