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.
Update 2019-04-23 Google was very active on headless front and many updates happened
The answer below is valid for the v62 current version is v73 and it's updating all the time. https://www.chromestatus.com/features/schedule
I highly recommend checking puppeteer for any future development with headless chrome. It is maintained by Google and it installs required Chrome version together with npm package so you just use puppeteer API by the docs and not worry about Chrome versions and setting up the connection between headless Chrome and dev tools API which allows doing 99% of the magic.
Update 2017-10-29 Chrome has already --dump-html flag which returns full HTML, not only body.
v62 does have it, it is already on stable channel.
Issue which fixed this: https://bugs.chromium.org/p/chromium/issues/detail?id=752747
Current chrome status (version per channel) https://www.chromestatus.com/features/schedule
Leaving old answer for legacy