Last active
September 11, 2019 16:02
-
-
Save linxinemily/f4a621d0f9e085b5665c1bf394a0c7ad to your computer and use it in GitHub Desktop.
puppeteer
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 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