aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/contentviews/html_outline.py
blob: d6c51b294c9569ad2d48352dc36366ed15b80785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import html2text

from mitmproxy.contentviews import base


class ViewHTMLOutline(base.View):
    name = "HTML Outline"
    prompt = ("html outline", "o")
    content_types = ["text/html"]

    def __call__(self, data, **metadata):
        data = data.decode("utf-8", "replace")
        h = html2text.HTML2Text(baseurl="")
        h.ignore_images = True
        h.body_width = 0
        outline = h.handle(data)
        return "HTML Outline", base.format_text(outline)