Last active
August 25, 2020 01:53
-
-
Save jasonappah/b3a547dcd11202e283b285caeec22b91 to your computer and use it in GitHub Desktop.
Screenshot
This file contains hidden or 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
// note to all who see this - i haven't tested this yet so I have no idea if it works yet | |
const puppeteer = require('puppeteer') | |
const browser = await puppeteer.launch(); | |
const color = "#00ff00" | |
const width = 1920 | |
const height = 1080 | |
const page = await browser.newPage(); | |
await page.setViewport({ | |
width : width, | |
height: height | |
}); | |
// sets a page color | |
page.setContent(`<style>body{background-color: ${color};}</style>`) | |
// loads a page, but we don't need that for this purpose. just here for reference | |
// page.goTo("someurl") | |
console.log(await page.content()); | |
await page.screenshot({path: 'screenshot.png'}); | |
await browser.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment