I want to dump the current DOM to a file and be able to view it offline. Essentially, I have an outdated version of a page that I would like to keep around for comparison. As soon as I close my browser, I'm going to lose it so I would like to save the DOM exactly as it is.
There is already an answer for doing this in Firefox but how do I do it in Chrome?
I am currently using version 53.0.2785.113 m of Chrome. The other answers no longer appear to be valid. To properly copy all child/descendant elements the user now has to right click on
<html>
then click "Expand All" before copying. Other wise you will not recursively copy all elements. A normal Ctrl+C will copy everything one<html>
has been expanded.Using the Web Inspector (F12), go to the Elements tab, right click on the
<html>
tag in your code and selectCopy
->Copy outerHTML
. Then paste that into a new file and save.Command line solution
This is easy to do with newer releases of Chrome:
(The OP may not have been looking for a command line solution but this search result appears high when searching so others might find it useful)
Original answer 2017
My favorite way to do this is:
If you're not familiar with how Docker works, be patient - the first time will be slow but subsequent invocations will be quick.
Other information
Tested on
Ubuntu 16
Docker version:
Mac OS X Sierra
Docker version:
If you install
tidy
you can indent the HTML too.