Skip to content

Instantly share code, notes, and snippets.

@kjk kjk/pupdl.js
Created Nov 17, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.