Skip to content

Instantly share code, notes, and snippets.

@jasonappah
Last active August 25, 2020 01:53
Show Gist options
  • Save jasonappah/b3a547dcd11202e283b285caeec22b91 to your computer and use it in GitHub Desktop.
Save jasonappah/b3a547dcd11202e283b285caeec22b91 to your computer and use it in GitHub Desktop.
Screenshot
// 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