-
-
Save svx/77d2a9897b02c6fae3ef8ea42a789d41 to your computer and use it in GitHub Desktop.
A small script using puppeteer to get screenshots of multiple browser pages.
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 puppeteer = require("puppeteer"); | |
const pages = require("./webPages.json"); | |
async function takeMultipleScreenshots() { | |
try { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
for (const { id, name, url } of pages) { | |
await page.goto(url); | |
await page.screenshot({ path: `screenshot${id}.jpeg`, fullPage: true }); | |
console.log(`${name} - (${url})`); | |
} | |
} catch (err) { | |
console.log(`Error: ${err.message}`); | |
} | |
} | |
takeMultipleScreenshots(); |
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
[ | |
{ | |
"id": "c1472465-ede8-4376-853c-39274242aa69", | |
"url": "https://github.com/microsoft/vscode", | |
"name": "VSCode" | |
}, | |
{ | |
"id": "6b08743e-9454-4829-ab3a-91ad2ce9a6ac", | |
"url": "https://github.com/vuejs/vue", | |
"name": "vue" | |
}, | |
{ | |
"id": "08923d12-caf2-4d5e-ba41-3019a9afbf9b", | |
"url": "https://github.com/tailwindlabs/tailwindcss", | |
"name": "tailwindcss" | |
}, | |
{ | |
"id": "daeacf42-1ab9-4329-8f41-26e7951b69cc", | |
"url": "https://github.com/getify/You-Dont-Know-JS", | |
"name": "You Dont Know JS" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment