October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober 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

How to Capture Website Screenshots with an AI Agent from a CSV URL List

Use an AI agent to help build a Python and Playwright script that reads URLs from a CSV, captures screenshots, and tracks each row’s result.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the AI agent to help write or operate the automation, but let a script explicitly read each CSV row and send its URL to a browser. Python’s csv.DictReader can map a header such as url to each record, and Playwright’s Python API can capture viewport, full-page, or element screenshots. The example below saves one image per valid row and records successes and errors so the results stay tied to the source list.

What the workflow does—and what the agent does

A CSV is input data, not an instruction to a browser. The script must open it, read the URL column, validate each value, navigate to the URL, capture the page, and record the result. An AI coding agent can generate or modify that script and help explain errors. Playwright also documents a command-line interface for coding-agent browser workflows, but its cited documentation does not describe a built-in CSV batch importer. Playwright’s coding-agent CLI documentation

As an Amazon Associate I earn from qualifying purchases.

This division keeps the batch process inspectable: the script owns the row-to-image mapping and error handling; the agent assists rather than silently deciding what to capture.

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.

Prepare the CSV and choose what to capture

Use a clear URL column

Make a header row with a field such as url, then put one URL in that column per record. The example uses Python’s DictReader, which maps row values to header names. Opening a CSV with newline='' follows the standard-library documentation. Python csv documentation

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • 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

Before navigation, check that the header exists and that each value is non-empty and has an acceptable URL scheme, typically http or https. The script below marks invalid rows as errors rather than trying to navigate to them.

Choose viewport, full-page, or element capture

  • Viewport: captures the visible browser area at the configured viewport size.
  • Full page: use full_page=True when content below the fold belongs in the image. This can produce a tall image.
  • Element: capture a specific component when the whole page is unnecessary; Playwright supports screenshots from a locator.
  • File or bytes: pass a path to save directly, or use screenshot bytes if another step needs to process or transfer the image.

These capture choices are documented by Playwright’s screenshot guide. Keep browser, viewport, capture scope, and file format consistent when you intend to compare runs; the website itself can still change between captures.

Install the tools

Use a supported Python installation, then install Playwright and its browser binaries:

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 | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • 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
  1. Install the Python package: python -m pip install playwright.
  2. Install Chromium for Playwright: python -m playwright install chromium.
  3. Save the script below as capture_csv.py, and create urls.csv with a url header.
  4. Run it with python capture_csv.py urls.csv.

These commands install the package and browser for the local environment where the script runs. If your system uses python3 instead of python, substitute that command consistently.

Runnable Python batch script

This script writes screenshots into screenshots/ and a results.csv manifest. Filenames include the CSV row number and hostname, so two URLs on the same site do not overwrite each other merely because their paths match. The screenshot and manifest paths are workflow choices; Playwright provides the navigation and screenshot primitives.

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

from playwright.sync_api import sync_playwright


def safe_host(url):
    host = urlparse(url).hostname or "unknown-host"
    return re.sub(r"[^A-Za-z0-9.-]+", "_", host)


def valid_url(value):
    if not value:
        return False
    parsed = urlparse(value)
    return parsed.scheme in ("http", "https") and bool(parsed.netloc)


def main(csv_path):
    output_dir = Path("screenshots")
    output_dir.mkdir(parents=True, exist_ok=True)
    results = []

    with open(csv_path, newline="", encoding="utf-8-sig") as source:
        reader = csv.DictReader(source)
        if not reader.fieldnames or "url" not in reader.fieldnames:
            raise ValueError("CSV must have a header named 'url'.")

        with sync_playwright() as playwright:
            browser = playwright.chromium.launch()
            page = browser.new_page(viewport={"width": 1440, "height": 900})

            for row_number, row in enumerate(reader, start=2):
                url = (row.get("url") or "").strip()
                filename = ""
                status = "error"
                error = ""

                if not valid_url(url):
                    error = "Missing or invalid http(s) URL"
                else:
                    filename = f"{row_number:05d}_{safe_host(url)}.png"
                    try:
                        page.goto(url, wait_until="load", timeout=30000)
                        page.screenshot(path=str(output_dir / filename), full_page=True)
                        status = "ok"
                    except Exception as exc:
                        error = f"{type(exc).__name__}: {exc}"

                results.append({
                    "row": row_number,
                    "url": url,
                    "filename": filename,
                    "status": status,
                    "error": error,
                })

            browser.close()

    with open("results.csv", "w", newline="", encoding="utf-8") as manifest:
        fields = ["row", "url", "filename", "status", "error"]
        writer = csv.DictWriter(manifest, fieldnames=fields)
        writer.writeheader()
        writer.writerows(results)

    failures = sum(result["status"] != "ok" for result in results)
    print(f"Processed {len(results)} rows; {failures} failed. See results.csv")


if __name__ == "__main__":
    if len(sys.argv) != 2:
        raise SystemExit("Usage: python capture_csv.py urls.csv")
    main(sys.argv[1])

The sample waits for the page load event and then captures a full page. That is a practical default, not a guarantee that every site has finished rendering dynamic content. If a page needs a particular element or delay, adjust the wait strategy before taking its screenshot.

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.

Adapt the capture to your task

Capture only the visible viewport

Change page.screenshot(path=str(output_dir / filename), full_page=True) to page.screenshot(path=str(output_dir / filename)). The resulting image uses the page’s current viewport, here configured as 1440 by 900 pixels.

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

Wait for a page-specific element

When a page renders important content after initial load, wait for a selector before capturing, for example:

page.goto(url, wait_until="domcontentloaded", timeout=30000)
page.locator("main").wait_for(timeout=15000)
page.screenshot(path=str(output_dir / filename), full_page=True)

Replace main with a selector that actually identifies the content you need. A missing selector will time out; handle that error in the row’s manifest rather than treating the capture as successful.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • 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

Capture one element or return image bytes

For a component capture, identify it with a locator and call page.locator(".product-card").screenshot(path="card.png"). To use the screenshot in a later processing step instead of writing it immediately, call image_bytes = page.screenshot(full_page=True); Playwright returns the screenshot data as bytes. See Playwright screenshot options.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Operate the workflow with an AI agent

Give the agent the expected CSV header, desired capture scope, viewport, output naming rule, and how failures should be recorded. Ask it to explain code changes and preserve the row number and original URL in the manifest. For example: “Update this script to capture the visible viewport, wait for the selector main article, and write each row’s URL, filename, status, and error to results.csv.”

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

If using Playwright’s coding-agent CLI interactively, follow the current CLI instructions for your installed version. The CLI documentation supports agent-oriented browser use; do not assume it imports and processes CSV rows on its own. Playwright coding agents guide

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.

Check results, reliability, and cost

  • Run a few rows first and inspect whether the chosen viewport or full-page scope produces the intended deliverable.
  • Use results.csv to compare each source URL with its output filename and status. Failed rows remain visible instead of shifting later images into misleading names.
  • For recurring jobs, decide whether to retry selected failures and how to handle duplicate URLs; the sample records failures but does not automatically retry or deduplicate.
  • Keep a stable viewport and capture method for comparisons, but allow for sites changing their content or rendering between runs.
  • A local Playwright run gives you direct control over browser code and filenames, while you operate and maintain the local browser environment. No throughput, success-rate, or pixel-identical-output guarantee follows from this example.

Common errors and fixes

“CSV must have a header named ‘url’”

Rename the header to exactly url, or change the script’s header check and row.get("url") lookup to match your actual column. Check for accidental spaces in the header.

Missing or invalid URL

Fill in the row’s URL and ensure it includes http:// or https:// plus a hostname. Blank and malformed rows are recorded as errors without navigation.

Browser executable is missing

Run python -m playwright install chromium in the same Python environment where Playwright was installed.

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

Navigation timeout or failed page load

The site may be slow, unavailable, or waiting on resources that do not complete. Confirm the URL in a browser, then adjust the timeout or use an appropriate navigation wait condition for the site. The sample records the exception and continues to the next row.

Screenshot is blank or incomplete

Check that the URL loaded the expected page and that its content is not rendered only after a later event. Wait for a meaningful selector or a suitable delay before capture, and inspect whether viewport capture or full-page capture matches the requirement.

Or skip the browser setup

If you want the CSV loop but not a local browser installation, have your script send each validated URL to ScreenshotNeo, a website screenshot API and MCP server. Its one-request API returns a screenshot or PDF; the URL below is the service’s documented endpoint example, so substitute the current row’s URL and your API key. See the ScreenshotNeo API documentation for request options.

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

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for free and get 1,000 screenshots a month with no card.

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

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.