October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk7 min

Capture Screenshots of Webpages Listed in a CSV with Python

A practical Python and Playwright workflow for reading URL rows from a CSV, saving uniquely named screenshots, and tracking failures.

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.

Use Python’s built-in csv module to read a URL column, then Playwright to open each page and save a uniquely named screenshot. The script below reuses one browser, records row-level errors instead of stopping the batch, and can capture either the visible viewport or the full page.

Install Playwright and its browser

The CSV reader is part of Python’s standard library; Playwright handles browser navigation and screenshots. Install the package and its browser binaries from a terminal:

As an Amazon Associate I earn from qualifying purchases.

  1. python -m pip install playwright
  2. python -m playwright install chromium

Playwright’s Python setup and browser options are documented at Playwright for Python. This example uses Chromium; Playwright also supports Firefox and WebKit.

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

Prepare the CSV

Save a comma-separated file such as pages.csv with a header named url and one URL per row:

#1 Best Overall
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
url
https://example.com/
https://www.python.org/

The script expects that exact header, ignoring leading or trailing spaces in header names. It skips empty URL cells and reports them in the results file. If your export uses a different delimiter or header, adjust and inspect the input rather than assuming all spreadsheet exports are alike. Python’s csv module documentation describes DictReader, which maps each row to a dictionary keyed by the column names.

Run the batch screenshot script

Save this as capture_csv.py in the same folder as pages.csv. It writes screenshots into screenshots/ and a row-by-row outcome log to capture_results.csv.

import csv
import re
from pathlib import Path
from urllib.parse import urlsplit

from playwright.sync_api import sync_playwright

INPUT_CSV = Path("pages.csv")
OUTPUT_DIR = Path("screenshots")
RESULTS_CSV = Path("capture_results.csv")
URL_COLUMN = "url"
FULL_PAGE = True


def safe_host(url):
    """Return a filesystem-safe hostname, or 'unknown-host' if parsing fails."""
    try:
        host = urlsplit(url).hostname or "unknown-host"
        return re.sub(r"[^A-Za-z0-9.-]+", "_", host)
    except ValueError:
        return "unknown-host"


def main():
    OUTPUT_DIR.mkdir(parents=True, exist_ok=True)

    with INPUT_CSV.open("r", encoding="utf-8", newline="") as csv_file:
        reader = csv.DictReader(csv_file)
        if not reader.fieldnames:
            raise ValueError("CSV is empty or has no header row")

        # Normalize whitespace around header labels, but keep row values unchanged.
        reader.fieldnames = [name.strip() if name else "" for name in reader.fieldnames]
        if URL_COLUMN not in reader.fieldnames:
            raise ValueError(
                f"Expected a '{URL_COLUMN}' column; found {reader.fieldnames}"
            )

        with RESULTS_CSV.open("w", encoding="utf-8", newline="") as results_file:
            writer = csv.DictWriter(
                results_file,
                fieldnames=["row", "url", "status", "screenshot", "error"],
            )
            writer.writeheader()

            with sync_playwright() as playwright:
                browser = playwright.chromium.launch()
                try:
                    page = browser.new_page()
                    for row_number, row in enumerate(reader, start=2):
                        url = (row.get(URL_COLUMN) or "").strip()
                        if not url:
                            writer.writerow({
                                "row": row_number, "url": "", "status": "skipped",
                                "screenshot": "", "error": "blank URL",
                            })
                            continue

                        screenshot_path = OUTPUT_DIR / (
                            f"row-{row_number:04d}-{safe_host(url)}.png"
                        )
                        try:
                            page.goto(url, wait_until="load", timeout=60000)
                            page.screenshot(
                                path=str(screenshot_path),
                                full_page=FULL_PAGE,
                            )
                            writer.writerow({
                                "row": row_number, "url": url, "status": "saved",
                                "screenshot": str(screenshot_path), "error": "",
                            })
                        except Exception as exc:
                            writer.writerow({
                                "row": row_number, "url": url, "status": "failed",
                                "screenshot": "", "error": str(exc),
                            })
                finally:
                    browser.close()


if __name__ == "__main__":
    main()

Run it with python capture_csv.py. Screenshot filenames include the CSV row number and sanitized hostname, so repeated hosts still get distinct files. The header occupies row 1, so the first data row is logged as row 2. Browser startup happens once, while each page is processed sequentially. A failed navigation or screenshot is logged and does not prevent later rows from being attempted.

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

Choose what each screenshot includes

Viewport or full page

With FULL_PAGE = True, Playwright requests a full-page screenshot; set it to False to capture only the current viewport. Full-page capture may produce tall images, and some pages load content only as the reader scrolls. The setting does not guarantee that every site’s lazy-loaded content has appeared before capture.

Specific element instead of the whole page

For a particular element, use a locator screenshot rather than page.screenshot. For example, after navigating, replace the screenshot call with:

page.locator("main article").screenshot(path=str(screenshot_path))

Change the CSS selector to match the element you need. A locator screenshot captures the matched element; it can fail if that element is missing or detaches while the page changes. See Playwright’s screenshot documentation.

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.

Format, quality, and repeatability

Playwright can save screenshots to a path or return image bytes. Screenshot options include output type, quality where supported, and pixel scale; consult the Page API for the exact arguments and format constraints. To use JPEG, for example, change the filename extension to .jpg and pass type="jpeg". Quality applies to supported lossy formats, not PNG.

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

Pages with animation or changing content may vary between runs. Locator screenshots support disabling animations; consult the Locator API if you need that behavior for an element capture. For consistent whole-page captures, consider a fixed viewport and capture timing that suits the site; no single wait condition ensures all pages have finished their own dynamic work.

Adjust input handling and capture behavior

CSV encoding and delimiters

The example opens UTF-8 CSV files with newline="", as recommended for the CSV module. If your file uses another encoding, replace encoding="utf-8" with the encoding that matches the source. If it is tab-separated or uses another delimiter, pass that delimiter when constructing the reader, for example csv.DictReader(csv_file, delimiter="t").

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

Navigation timing and URLs

The script waits for the browser’s load event and allows up to 60 seconds per navigation. A site that continuously loads resources may need a different wait condition; a faster event can capture earlier, but may omit content that has not rendered yet. URLs should include their scheme, such as https://. Pages that require a login, reject automated browsing, or show consent prompts can behave differently from a normal visit.

Filename and output changes

Change OUTPUT_DIR to choose another folder, and change the screenshot suffix and options to select another image type. The hostname is sanitized for filesystem use, while the row number preserves uniqueness even when a URL is repeated. The results CSV makes blank rows and failures distinguishable from successful captures.

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

Troubleshoot common problems

  • “Expected a ‘url’ column”: Check the spelling and whitespace of the CSV header, then confirm that the file actually has a header row. Set URL_COLUMN to the real column name if it differs.
  • No browser executable found: Install the browser binary with python -m playwright install chromium after installing the Python package.
  • Timeout or navigation error: Check that the URL is reachable from your machine and includes https:// or http://. The failing row is recorded in capture_results.csv; adjust the timeout or wait condition for sites with unusual loading behavior.
  • Screenshot is blank, incomplete, or shows a challenge: Check the page manually and review its loading behavior, login needs, or automated-traffic restrictions. The script cannot guarantee a successful or complete capture for every site.
  • Wrong characters or a single-column import: Verify the source encoding and delimiter. Set the matching encoding or delimiter in the reader.
  • One failure stops later rows: In the provided script, exceptions inside each row are caught and logged. Errors outside that per-row block, such as an invalid CSV header or browser launch failure, stop the run because the batch cannot proceed safely.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Runtime, reliability, and cost considerations

This local workflow launches a browser once and handles rows sequentially, which avoids the overhead of launching a new browser for every URL. Total runtime depends on page response and rendering behavior; the 60-second navigation timeout is a per-navigation ceiling, not a promise that every row will finish within that time. Very large batches can take a while and produce substantial image files, especially with full-page captures.

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.

Playwright itself is software you install and run locally; the cited documentation does not establish a per-screenshot service charge. Sites may still require credentials, block automation, or present content that differs from a standard visitor session. Keep the CSV and screenshots in a location appropriate for the sensitivity of the URLs and captured pages.

Or skip the browser setup

If you would rather request captures from an API than install and run a browser, ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. This cURL example saves a WebP screenshot:

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

See the ScreenshotNeo documentation for API details. For a CSV batch, call the endpoint once for each URL and choose a distinct output filename in your own script. ScreenshotNeo removes cookie and consent banners, 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 report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

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

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

Frequently Asked Questions

Can I capture a CSV that has no header row?

The script expects a header named url. Add a header row or change the reader logic to treat rows as positional data.

Can I capture pages that require a login?

Not with the script exactly as written; authenticated sites may require browser context cookies or another sign-in setup, and the result depends on the site.

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.

Leave a Reply

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

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.

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.