Created
September 6, 2021 09:55
-
-
Save oofnivek/e76d560621d08dd0a59c4e7e22ba4b27 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'); | |
function sleep(ms) { | |
return new Promise((resolve) => { | |
setTimeout(resolve, ms); | |
}); | |
} | |
const get_html = async() => { | |
const browser = await puppeteer.launch({ | |
defaultViewport: {width: 1920, height: 1080} | |
//,args: [ '--proxy-server=192.168.1.234':3128' ] | |
}); | |
const page = await browser.newPage(); | |
//await page.setDefaultNavigationTimeout(10000) | |
await page.goto('https://www.google.com/search?q=bitcoin'); | |
//await sleep(1000); | |
var html = await page.content(); | |
await page.screenshot({path: 'screenshot.png'}); | |
browser.close(); | |
return html; | |
}; | |
get_html() | |
.then(html => { | |
fs.writeFileSync('source.htm', html); | |
}) | |
.catch(error => { | |
console.log(error); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment