I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
# Extracting HTML from a Loaded Chrome Page You have a few options to save the HTML of the page that's already loaded in your browser: ## Option 1: Copy to clipboard (simplest) Type this in the Chrome console:
1 | copy(document.documentElement.outerHTML) |
1 2 3 4 5 6 7 8 9 10 | (function() { const html = document.documentElement.outerHTML; const blob = new Blob([html], {type: 'text/html'}); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'page-backup.html'; a.click(); URL.revokeObjectURL(url); })(); |
1 | document.documentElement.outerHTML |
Testing if the previous output contains the string outerHTML
: True
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
# Getting a Copy of Webpage HTML from the Console Here are two effective ways to get a copy of the entire HTML from a page that's already loaded in your browser: ## Option 1: Copy to Clipboard This simple one-liner will copy the entire HTML to your clipboard:
1 | copy(document.documentElement.outerHTML); |
1 2 3 4 5 6 7 8 9 10 | (function() { const html = document.documentElement.outerHTML; const blob = new Blob([html], {type: 'text/html'}); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'page_backup.html'; a.click(); URL.revokeObjectURL(url); })(); |
Testing if the previous output contains the string outerHTML
: True