Created
August 13, 2021 07:26
-
-
Save oofnivek/3c80e2139722c2b4525575618b3c0659 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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