Skip to content

Instantly share code, notes, and snippets.

@linxinemily
Created September 11, 2019 16:03
Show Gist options
  • Save linxinemily/c7f5dd3fd2a06bee0d070263dbfc01c9 to your computer and use it in GitHub Desktop.
Save linxinemily/c7f5dd3fd2a06bee0d070263dbfc01c9 to your computer and use it in GitHub Desktop.
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({ encoding: 'base64'})
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