Skip to content

Instantly share code, notes, and snippets.

@oofnivek
Created August 13, 2021 07:26
Show Gist options
  • Save oofnivek/3c80e2139722c2b4525575618b3c0659 to your computer and use it in GitHub Desktop.
Save oofnivek/3c80e2139722c2b4525575618b3c0659 to your computer and use it in GitHub Desktop.
const puppeteer = require('puppeteer');
const fs = require('fs');
async function run () {
const browser = await puppeteer.launch({
defaultViewport: {width: 1920, height: 1080}
});
const page = await browser.newPage();
await page.goto('https://www.google.com/search?q=bitcoin');
await sleep(3000);
await page.screenshot({path: 'screenshot.png'});
const html = await page.content();
fs.writeFileSync('source.htm', html);
browser.close();
}
run();
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment