How to dump more than <body> on chrome / chromium headless?

Viewed 6522

Chrome's documentation states:

The --dump-dom flag prints document.body.innerHTML to stdout:

As per the title, how can more of the DOM object (ideally all) be dumped with Chromium headless? I can manually save the entire DOM via the developer tools, but I want a programmatic solution.

2 Answers

You are missing --headless to get stdout.

chromium --incognito \
         --proxy-auto-detect \
         --temp-profile \ 
         --headless \
         --dump-dom https://127.0.0.1:8080/index.html

Pipe it all in | html2text to recompile html into text.

Related