Skip to content

Instantly share code, notes, and snippets.

@linxinemily
Last active September 11, 2019 16:02
Show Gist options
  • Save linxinemily/f4a621d0f9e085b5665c1bf394a0c7ad to your computer and use it in GitHub Desktop.
Save linxinemily/f4a621d0f9e085b5665c1bf394a0c7ad to your computer and use it in GitHub Desktop.
puppeteer
const browser: Browser = await puppeteer.launch()
const page: Page = await browser.newPage()
await page.setViewport({ width: 1440, height: 900 })
await page.goto(url, { waitUntil: ['networkidle2'], timeout: 0 })
const screenshot = await page.screenshot({
type: 'jpeg',
encoding: 'base64',
quality: 50
})
await browser.close()
const src = `data:image/jpeg;base64,${screenshot}`
res(new responseData(src, { name: 'screenshot' }))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment