Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Put the YouTube URLs in an array, reuse one Puppeteer page to visit them sequentially, and give each screenshot a unique filename. This is the simplest way to capture a small batch without overwriting files. The example below sets a consistent viewport, waits for navigation, records the HTTP status when available, and closes the browser even if a capture fails.

Capture multiple YouTube URLs sequentially

Puppeteer’s documented screenshot workflow is to launch a browser, create a page, navigate to a URL, call Page.screenshot(), and close the browser. For a short list, one page can visit each URL in turn. A numbered filename gives every capture its own output path.

The example uses JavaScript modules and assumes Puppeteer is installed in the project. Replace the sample video IDs with the URLs you want to capture.

import puppeteer from 'puppeteer';

const urls = [
  'https://www.youtube.com/watch?v=VIDEO_ID_1',
  'https://www.youtube.com/watch?v=VIDEO_ID_2',
];

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.setViewport({ width: 1280, height: 720 });

  for (const [index, url] of urls.entries()) {
    const response = await page.goto(url, { waitUntil: 'networkidle2' });
    const filename = `youtube-${index + 1}.png`;
    await page.screenshot({ path: filename });
    console.log({ url, status: response?.status(), filename });
  }
} finally {
  await browser.close();
}

This follows the browser lifecycle shown in the Puppeteer screenshots guide. The files are written relative to the process’s current working directory; use a directory in the path if you want them elsewhere, and make sure that directory exists first.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Run it and locate the output

  1. Save the code in a JavaScript file in a project where Puppeteer is installed.
  2. Replace both VIDEO_ID_1 and VIDEO_ID_2 with valid video IDs, or replace the sample strings with complete YouTube URLs.
  3. Run the file with your project’s JavaScript runtime and module configuration.
  4. Check the printed URL, status, and filename for each attempt, then open the generated PNG files to verify what the pages actually displayed.

The loop is sequential: the next navigation does not begin until the current screenshot finishes. This makes the order and filename mapping easy to follow. If one URL throws an error during navigation or screenshot capture, the loop stops, but the finally block still closes the browser. If you need a batch to continue after individual failures, put a try/catch inside the loop and log the failed URL; do not silently treat a failed capture as a successful image.

Choose what part of each page to capture

The default page.screenshot() captures the page at its current viewport. Setting the viewport before navigation helps keep the images consistent. The Puppeteer API also supports a full-page capture, and the screenshots guide documents capturing a particular rendered element through ElementHandle.screenshot().

Viewport screenshot

Use the default screenshot when you want a consistent browser-window view, such as a comparison of the visible page area. The sample’s 1280-by-720 viewport is an example, not a universal ideal. Pick dimensions that match your downstream use and keep them unchanged across the batch when direct comparison matters.

Full-page screenshot

For a full-page image, change the screenshot call to:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
await page.screenshot({ path: filename, fullPage: true });

This asks Puppeteer to capture the full page rather than only the current viewport. A longer page can produce a much taller file, so use it only when below-the-fold content is part of the task.

One element

If you want a specific rendered element rather than the whole page, select it and call its screenshot method:

const playerOrTarget = await page.$('CSS_SELECTOR');
if (!playerOrTarget) {
  throw new Error('The requested element was not found');
}
await playerOrTarget.screenshot({ path: filename });

Replace CSS_SELECTOR with a selector for the element you need. A selector that matches one site state may not match another; verify it on representative URLs rather than assuming every video page has the same rendered structure. Puppeteer’s guide documents the element-handle approach at pptr.dev/guides/screenshots.

Wait for the page state you actually need

The sample uses waitUntil: 'networkidle2', a navigation readiness choice demonstrated in Puppeteer’s screenshot guide. It is not a promise that a dynamic page has reached the exact visual state you want. Navigation completion and the presence of the content you intend to capture are separate things.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

For a more deliberate capture, wait for a page-specific condition after navigation. For example, when a stable selector is appropriate for your target, add a selector wait before the screenshot:

await page.goto(url, { waitUntil: 'networkidle2' });
await page.waitForSelector('CSS_SELECTOR');
await page.screenshot({ path: filename });

Choose a condition that corresponds to the visual state your workflow requires. A selector can be absent, delayed, or changed, so handle a timeout as a failed or incomplete capture rather than saving it as if it were correct. Avoid choosing a condition just because it is easy to wait for: the page may satisfy it before the desired content is visible.

YouTube pages can render differently depending on the URL and environment. A successful navigation does not establish that the expected video, player, or other content appeared; a page may instead show a consent prompt, sign-in state, or another result. The Puppeteer documentation explains the browser API, not the exact state YouTube will serve to a particular run. Inspect sample output and validate the state your use case needs.

Save screenshots to files or handle image data

Passing path to page.screenshot() writes an image file. The screenshot API returns a Uint8Array by default when you do not use a path, and it also documents a base64 option. This is useful if the next step in your program consumes image bytes rather than a file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
const imageBytes = await page.screenshot();
// Pass imageBytes to code that accepts image data.

For a batch, keep the association between each URL and its returned image explicit—for example, store pairs of URL and image bytes or write each result immediately to a unique path. If every capture uses the same path, a later screenshot can replace an earlier one. The documented return behavior and screenshot options are in the Page.screenshot API.

When to use more than one page

Sequential reuse of one page is usually the clearest starting point: it limits simultaneous work and makes it straightforward to identify which URL produced each file. Puppeteer also allows multiple Page instances in a single browser. That can let a script process several URLs concurrently, but it also means more pages are active at once.

The Puppeteer Page API documents multiple pages and per-page viewports, but it does not prescribe a universally suitable concurrency limit. Start with a small bounded number, observe resource use and the behavior of your actual target pages, and adjust for your machine and workload. Do not launch one page per URL without a bound for a large input list.

For consistent captures, set each page’s viewport before navigating. Puppeteer warns that some sites do not expect viewport changes and that certain viewport property changes can reload a page. The API details are in the Page API. If you use multiple pages, give each task its own URL-to-filename mapping and ensure a failure in one task is reported rather than mistaken for a completed screenshot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check response status and browser lifecycle

The example logs response?.status() because navigation can return an HTTP response whose status is not a successful page result. Puppeteer’s Page API notes that in headless-shell navigation does not throw solely because a server returned a valid HTTP error status such as 404 or 500. Therefore, a resolved goto() call by itself does not tell you that the URL returned the response you expected. Check the status where available and define what your batch should do with non-success statuses.

Use try/finally around browser work so browser.close() is attempted if navigation or capture throws. The screenshot API also notes that, in the same BrowserContext, page creation and close operations wait for an in-progress screenshot to finish; bringToFront() does not. See the screenshot API for those operation details.

Troubleshoot common batch problems

  • Only one image remains: Every iteration may be using the same path. Include the index, video ID, or another unique value in the filename.
  • The screenshot is blank or shows an unexpected state: A completed navigation is not proof that the desired YouTube content rendered. Open the image, inspect the page state, and wait for a condition tied to the content you need.
  • A URL returns an error but the script continues: Check the navigation response status. A valid HTTP error response does not necessarily make navigation throw in headless-shell.
  • The selector capture fails: The selector may not exist in that page state. Check for a missing element before calling its screenshot method, and report which URL lacked it.
  • The batch stops at one problematic URL: An exception currently escapes the loop. Catch errors per URL if later captures should proceed, and record failures separately from successful filenames.
  • Concurrent runs consume too many resources or behave inconsistently: Reduce the number of active pages. There is no concurrency cap established by the API documentation; tune a bounded level against your environment.
  • The output is unexpectedly large: Confirm whether you enabled fullPage. A full-page capture can be much taller than a viewport capture.

Or skip the browser setup

If you want a screenshot API instead of managing a Puppeteer browser, ScreenshotNeo takes a URL in one GET request. Its clean-shot options accept cookie or consent banners as a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://www.youtube.com/watch?v=VIDEO_ID_1 -o shot.webp

Replace YOUR_API_KEY with your key and change the URL to the YouTube page you want. See the ScreenshotNeo API documentation for request options. The service supports PNG, JPEG, WebP, or PDF output and has options including full-page capture, element selection, viewport and device settings, waits, custom CSS or JavaScript, and bulk capture. Its plans include 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo, then sign up for 1,000 free screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Practical choices for a dependable workflow

  • Use one page and sequential navigation for a small, easy-to-debug list.
  • Use unique filenames or preserve each returned image alongside its source URL.
  • Choose viewport, full-page, or element capture based on the output your task needs.
  • Use a wait condition that checks for the desired rendered state, not just the end of navigation.
  • Check response status and inspect representative captures; do not assume a successful browser operation means the expected YouTube page appeared.
  • Only add bounded concurrency when the sequential version is too slow for your requirements, then observe actual resource use and results.

Frequently Asked Questions

Can Puppeteer take screenshots of multiple YouTube URLs in one run?

Yes. Put the URLs in an array and navigate to each one in a loop, or create multiple pages if you need bounded concurrent work.

Does networkidle2 guarantee that a YouTube video is ready in the screenshot?

No. It is a navigation wait condition, not confirmation that the particular video or page state you need has appeared.

Can I save the screenshot without writing a PNG file first?

Yes. Without a path, the screenshot API returns image bytes as a Uint8Array by default; it also documents a base64 overload.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.