Skip to content

Instantly share code, notes, and snippets.

@kjk
Created November 17, 2019 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjk/32e99090311dfb2012f12833b76576d1 to your computer and use it in GitHub Desktop.
Save kjk/32e99090311dfb2012f12833b76576d1 to your computer and use it in GitHub Desktop.
puppeteer download page (made with https://codeeval.dev)
'use strict';
const puppeteer = require('puppeteer');
const fs = require('fs');
(async function main() {
try {
const browser = await puppeteer.launch();
const [page] = await browser.pages();
const uri = 'https://www.notion.so/nopub/Using-Go-instead-of-bash-for-scripts-6b51885c1f6940aeb40476000d0eb0fc';
await page.goto(uri, {
waitUntil: 'networkidle2'
});
const data = await page.content()
//const cdp = await page.target().createCDPSession();
//const { data } = await cdp.send('Page.captureSnapshot', { format: 'mhtml' });
fs.writeFileSync('page.html', data);
await browser.close();
} catch (err) {
console.error(err);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment