October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Redmond desk7 min

How to Capture Screenshots of Multiple URLs with Selenium Python on Windows 11

Use one Selenium browser session to visit a URL list and save a separate PNG for each page, with waits, error handling, and practical Windows setup guidance.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use one Selenium WebDriver session, navigate to each URL in turn, wait for the page content you need, and save a uniquely named PNG for every page. On Windows 11, Selenium Manager generally handles browser-driver setup when you create the driver, so a separate driver download is usually unnecessary on supported installations.

Install Selenium and prepare the URL list

Use Python 3.10 or later, a supported browser installed on the machine, and a writable output folder. The Selenium Project documents Python bindings for Chrome, Edge, Firefox, Safari, WebKitGTK, and WPEWebKit; actual availability depends on your operating system and setup. Create and activate a virtual environment if you want to keep this project’s packages separate, then install or update Selenium:

As an Amazon Associate I earn from qualifying purchases.

py -m venv .venv
.venvScriptsactivate
python -m pip install -U selenium

These are Windows Command Prompt commands. In PowerShell, activate with ..venvScriptsActivate.ps1; if script execution is restricted, follow your organization’s policy rather than changing system policy blindly. See the Selenium Python documentation and the Selenium Project’s first script for setup guidance.

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

Capture each URL in one browser session

Save this as capture_urls.py. The numeric prefix prevents overwrites even when URLs share a hostname. The script creates the output folder, checks the screenshot method’s return value, reports a failure for an individual URL, and always closes the browser.

from pathlib import Path
from urllib.parse import urlparse
import re

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.common.exceptions import TimeoutException, WebDriverException

urls = [
    "https://example.com/",
    "https://www.selenium.dev/",
]
output_dir = Path("screenshots")
output_dir.mkdir(parents=True, exist_ok=True)


def safe_name(url: str) -> str:
    host = urlparse(url).netloc or "page"
    return re.sub(r"[^A-Za-z0-9._-]+", "_", host)[:100]


driver = webdriver.Chrome()
try:
    for index, url in enumerate(urls, start=1):
        try:
            driver.get(url)
            # Basic document readiness check; replace or supplement with a
            # page-specific condition when asynchronous content matters.
            WebDriverWait(driver, 10).until(
                lambda d: d.execute_script(
                    "return document.readyState"
                ) == "complete"
            )
            path = output_dir / f"{index:03d}_{safe_name(url)}.png"
            if not driver.save_screenshot(str(path)):
                raise OSError(f"Could not save screenshot to {path}")
            print(f"Saved {url} to {path}")
        except (TimeoutException, WebDriverException, OSError) as exc:
            print(f"Failed for {url}: {exc}")
finally:
    driver.quit()

Run it from the folder containing the file with python capture_urls.py. The paths are relative to the current working directory, not necessarily the script’s location. To make the output folder relative to the script instead, set output_dir = Path(__file__).resolve().parent / "screenshots".

Choose a wait that matches the page

driver.get(url) normally waits for the document’s configured ready state, which defaults to complete. That does not guarantee that JavaScript-driven content, API-loaded results, animations, or lazy-loaded images have finished. The Selenium Project explains this distinction in its Waiting Strategies guide.

Wait for a known element

For a page where a particular element signals that the important content is ready, wait for it explicitly:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

WebDriverWait(driver, 15).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "main article"))
)

Replace the selector with one that exists on the target page and appears only when the content you need is ready. A single selector may not fit a mixed list of unrelated sites, so keep per-site conditions in a mapping or function when necessary.

Rank #2
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

Adjust navigation and wait timeouts deliberately

Set a page-load timeout to prevent a slow navigation from waiting indefinitely, and use an explicit wait for the content condition afterward:

driver.set_page_load_timeout(30)
driver.get(url)
WebDriverWait(driver, 15).until(
    lambda d: d.find_element(By.CSS_SELECTOR, "main").is_displayed()
)

The timeout values here are examples, not universal guarantees; choose them for the sites and network you are capturing. Selenium’s Python WebDriver API documents the page-load timeout. Avoid combining implicit waits with explicit waits: Selenium warns that doing so can produce unpredictable timing. A fixed time.sleep() is simple, but may wait too long on fast pages and still be too short on slow ones.

Know what the screenshot contains

save_screenshot() captures the current browser window as a PNG; it is not, by itself, a full-page capture method. The Selenium Python screenshot API also documents get_screenshot_as_file(filename), which saves the current window and returns False on an I/O error. Use a valid writable path with a .png extension and check the return value. See the Python Chromium WebDriver screenshot API.

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

If you need the entire height of a long page, do not assume a normal window screenshot includes it. Choose and validate a browser-specific full-page technique separately, including how it handles fixed elements, lazy loading, and page height. The Selenium window documentation demonstrates the ordinary current-window screenshot workflow: Working with windows and tabs.

Rank #3

Handle larger URL lists safely

Keep names unique and inspect results

A hostname alone is not a unique filename: different pages may share a host, and repeating the same URL can otherwise overwrite an earlier capture. The example’s index guarantees a distinct filename for each position in the list. If you need stable filenames across runs, build a sanitized name from the full URL and add a short hash; retain an index if duplicate URLs should still produce separate files.

The sample continues after common navigation, wait, or file-write errors and prints each failure. For an auditable batch, write successes and failures to a CSV or log file, and validate URLs before starting. A failed URL can leave the browser on an error page or prior page; never treat a saved file as successful without checking the corresponding log and, when needed, the page verdict.

Reuse a session unless isolation is required

One browser session reused across the loop is simpler and avoids repeatedly starting browsers. It also means cookies, local storage, cache, and other browser state can carry over between URLs. Start a fresh driver per URL only when each capture needs an isolated browser state or one site’s state must not affect another; that approach has additional startup and resource overhead. There is no universal speed advantage established here, so choose based on isolation and operational needs.

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

Limit batch size and browser resources

For long batches, capture in manageable groups, monitor disk space, and consider restarting the driver between groups if browser memory use grows. Do not launch many browser instances at once unless the machine and target sites can support the extra CPU, memory, and network load. Selenium documentation does not establish a universal safe concurrency level.

Rank #4
Windows 11 Laptop with i3 Processor 15.6" Work Laptop for College Students
  • 【Efficient Performance】 Powered by Intel Core i3 processor (2 cores, 4 threads, up to 3.4GHz) with 12GB RAM and 256GB SSD. Handles multitasking, office software, online classes, and HD video streaming smoothly. Integrated Intel UHD Graphics 620
  • Backlit Keyboard & Complete Package】Comes with a cool backlit keyboard. Comes with awebcam, dual stereo speakers (8Ω/1.0W each), DC charger, and user manual – ready for late-night studying, online classes, video conferencing, and daily productivity
  • 【Vibrant Display】 15.6-inch Full HD (1920x1080) anti-glare screen with 16:9 aspect ratio delivers crisp images and vivid colors – perfect for studying, watching lectures, or entertainment. Thin-bezel design maximizes viewing area
  • 【Fast Connectivity & Expansion】 Equipped with WiFi 6 (802.11ax) and Bluetooth 5.2 for stable, high-speed wireless. Features 3 x USB 3.0, HDMI 2.1, Type-C (supports PD3.0 fast charging), and a TF card slot expandable up to 2TB – easily connect external monitors, mice, drives, or expand storage for all your files
  • 【Long Battery Life & Portable】 Built-in 11.55V 5000mAh/57.75Wh high-capacity battery delivers approximately 7 hours of mixed-use battery life – enough for a full day of classes and assignments. Lightweight at just 1.63kg (3.6 lbs) and 19.5mm thin, plus a compact packing size – easily slips into a backpack for campus, library, or coffee shop
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

  • Browser or driver fails to start: Confirm the browser is installed and Selenium is current. Selenium Manager normally resolves a driver for supported setups when WebDriver starts; automatic resolution can still be blocked by network restrictions, permissions, or local configuration. In a restricted environment, consult Selenium’s official driver-location instructions and configure an explicit service path rather than assuming driver management can reach the network.
  • A screenshot is missing: Check the current working directory, confirm the destination exists and is writable, preserve the .png extension, and inspect the boolean returned by save_screenshot().
  • Files overwrite each other: Include a sequence number or another unique key in each filename; hostnames and final URL path segments are not sufficient for arbitrary lists.
  • The page is blank or content is incomplete: Wait for a page-specific element or state instead of relying only on document readiness. Check whether the content is behind a login, blocked by a bot check, or loaded only after scrolling or interaction.
  • A wait times out: Verify the selector against the page’s actual DOM, allow an appropriate timeout, and distinguish a slow page from a condition that never becomes true. Catch timeouts per URL if the batch should continue.
  • The browser remains open after an error: Keep driver.quit() in a finally block so cleanup runs when capture or saving fails.
  • The capture cuts off a long page: Standard current-window capture is not full-page capture. Select and test a separate method for the chosen browser rather than relying on the ordinary screenshot call.

Or skip the browser setup

ScreenshotNeo can capture a URL through one GET request and return an image or PDF; the example below saves a WebP response. Its clean-shot options accept consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture, and those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers identify the page verdict and billing status. Its MCP server provides screenshot, page-info, and PDF tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. See the ScreenshotNeo API documentation for request options and response details.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/ -o shot.webp

Get an API key with 1,000 free screenshots a month, no card required.

Frequently Asked Questions

Does this script capture a full webpage?

No. Selenium’s ordinary screenshot call captures the current browser window; full-page capture requires a separate browser-specific method.

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

Can I save the screenshots as JPEG instead of PNG?

The Selenium methods shown here save PNG files. Converting or capturing another format requires a separate step or a different capture approach.

Quick Recap

Bestseller No. 1
Bestseller No. 2
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$285.00
Bestseller No. 3
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$245.99

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.