Use Python’s built-in csv module to read a url column, then use Playwright to open each page and save a separate screenshot. The script below reuses one browser, names files safely, records row-level errors, and lets you choose viewport or full-page captures.
What you need
- Python installed on your computer.
- A CSV file with a header named
urland one webpage address per row. - Playwright and its browser binaries. Install them with
python -m pip install playwright, thenpython -m playwright install chromium. Playwright supports Chromium, Firefox, and WebKit; this example uses Chromium.
Python’s csv module reads and writes tabular CSV data without an additional CSV package. Its DictReader maps each row to a dictionary using the header names. Open the file with newline="" so the CSV module can handle line endings correctly. [Python csv documentation]
Prepare the CSV
Save a file such as pages.csv with a header row and a url column:
url
https://example.com/
https://www.python.org/
https://playwright.dev/python/
The script expects that header exactly, apart from capitalization and surrounding whitespace. If your spreadsheet export uses another delimiter, such as a semicolon, set the matching delimiter in the csv.DictReader call. Check the file’s first line if the script reports a missing header.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Install Playwright
- Install the Python package:
python -m pip install playwright. - Install the Chromium browser binary:
python -m playwright install chromium. - Save the script below as
capture_csv.pyin the same folder aspages.csv, or change the input path in the script.
Playwright’s Python documentation covers installation and the browser, page, navigation, and screenshot APIs used here. [Playwright for Python]
Run the complete script
This synchronous script writes images into a screenshots folder and a results.csv log. It saves one output per valid URL row, continues after an individual navigation or capture error, and closes the browser even if the batch is interrupted by an exception.
import csv
import re
from pathlib import Path
from urllib.parse import urlparse
from playwright.sync_api import sync_playwright
INPUT_CSV = Path("pages.csv")
OUTPUT_DIR = Path("screenshots")
RESULTS_CSV = Path("results.csv")
URL_COLUMN = "url"
FULL_PAGE = True
def safe_hostname(url: str) -> str:
"""Return a filesystem-safe hostname, or 'page' if parsing fails."""
try:
hostname = urlparse(url).hostname or "page"
except ValueError:
hostname = "page"
return re.sub(r"[^A-Za-z0-9.-]+", "_", hostname).strip("._") or "page"
def main() -> None:
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)
headers = reader.fieldnames or []
normalized_headers = {header.strip().lower() for header in headers if header}
if URL_COLUMN not in normalized_headers:
raise ValueError(
f"CSV must have a '{URL_COLUMN}' header; found: {headers}"
)
# Resolve the actual header spelling, including whitespace/capitalization.
actual_url_column = next(
header for header in headers
if header and header.strip().lower() == URL_COLUMN
)
rows = list(reader)
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(viewport={"width": 1440, "height": 900})
for row_number, row in enumerate(rows, start=2):
url = (row.get(actual_url_column) or "").strip()
if not url:
writer.writerow({
"row": row_number,
"url": "",
"status": "skipped",
"screenshot": "",
"error": "Blank URL",
})
continue
filename = f"{row_number:04d}_{safe_hostname(url)}.png"
screenshot_path = OUTPUT_DIR / filename
try:
page.goto(url, wait_until="load", timeout=30000)
page.screenshot(path=str(screenshot_path), full_page=FULL_PAGE)
writer.writerow({
"row": row_number,
"url": url,
"status": "ok",
"screenshot": str(screenshot_path),
"error": "",
})
print(f"Saved {screenshot_path} for {url}")
except Exception as error:
writer.writerow({
"row": row_number,
"url": url,
"status": "error",
"screenshot": "",
"error": str(error),
})
print(f"Failed row {row_number} ({url}): {error}")
finally:
browser.close()
if __name__ == "__main__":
main()
Run it with:
python capture_csv.py
Rows are numbered from 2 because row 1 is the CSV header. Including the row number in each filename keeps captures distinct even when several rows point to the same hostname. The result log uses the same row numbers and shows skipped blank values and failures as well as successful output paths.
Choose what the screenshot includes
Viewport or full page
The sample sets FULL_PAGE = True, which asks Playwright to capture the full scrollable page. Set it to False to capture only the visible viewport, sized here at 1440 by 900 CSS pixels. Full-page captures can be much taller and larger than viewport images. [Playwright screenshots]
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteRank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Wait for content that appears after navigation
The sample navigates with wait_until="load". That waits for the page’s load event, but it does not guarantee that every site-specific script, animation, or lazy-loaded asset has finished. If a target needs extra time, add a short delay after page.goto, or wait for a known element with page.locator("CSS_SELECTOR").wait_for(). Use a selector that actually appears on the target site; an incorrect selector will cause a timeout.
For pages that populate content as you scroll, a full-page screenshot may not trigger every site’s lazy-loading behavior. If lower sections are missing, scroll through the page before capturing or use a site-specific wait strategy. Login walls, consent prompts, bot checks, and other site behavior may also affect the resulting image.
Capture one element instead of the page
To save a specific element, wait for its locator and call screenshot on it rather than on the page:
card = page.locator(".product-card").first
card.wait_for(state="visible", timeout=10000)
card.screenshot(path="screenshots/product-card.png")
Element screenshots target the matched element and can fail if it is detached while capture is underway. For a whole-page image, use page.screenshot. [Playwright screenshots] [Playwright locator screenshot API]
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Change the format or rendering scale
The example saves PNG files. Playwright also supports JPEG and, where supported by the API, a quality setting for JPEG output. The screenshot options include scale choices that affect output pixel dimensions. Use the screenshot API documentation for the exact options supported by your installed Playwright version. [Playwright page screenshot API]
Handle CSV variations safely
Different text encoding
The script opens the input as UTF-8. If the file comes from a spreadsheet application that exports a different encoding, use the encoding appropriate to that file, such as utf-8-sig for a UTF-8 file with a byte-order mark. If decoding fails, do not silently replace characters: confirm the source file’s encoding and set it explicitly.
Unexpected header or delimiter
A missing url header raises a clear error before browser launch. Rename the CSV column to url, or change URL_COLUMN in the script. For a semicolon-separated export, use csv.DictReader(csv_file, delimiter=";"). For a file without headers, use csv.reader and read the URL from the correct column index instead.
Invalid or non-web addresses
The script reports navigation errors in results.csv. Make sure each populated cell contains a complete address such as https://example.com/. Relative paths and addresses without a usable scheme may not navigate as intended.
Recommended Free Tools
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Performance, reliability, and cost
For a modest list, sequential processing with one browser instance is a straightforward way to limit setup overhead and keep failures associated with individual rows. A slow or unresponsive site can still hold up the next row until the navigation timeout; adjust the timeout=30000 value to fit your pages and network. Raising the timeout may help slow sites but also makes stalled rows take longer.
Concurrent tabs or browser contexts can reduce elapsed time for large batches, but consume more memory and add complexity around rate limits, session state, and failure handling. The official API documentation establishes the core screenshot methods, not a recommended concurrency level for this CSV workflow. Start sequentially, inspect the results log, and add controlled concurrency only if measured runtime requires it.
Playwright itself is free to install; this workflow’s local costs are your machine, network connection, and time. The script does not bypass logins or anti-bot checks, and a successful navigation does not prove that a site rendered all dynamic content. Check representative output images when completeness matters.
Or skip the browser setup
If you prefer a hosted request instead of installing and maintaining a local browser, ScreenshotNeo can capture a URL via one GET request. For example, using cURL:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
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 API documentation for the API options. Its capture flow accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before the shot; each step can be disabled. 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. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.
Frequently Asked Questions
Can the script save a screenshot for every CSV row if one page fails?
Yes. It catches navigation or capture errors per row, records the failure in results.csv, and proceeds to the next row.
Does a full-page screenshot always include content loaded as I scroll?
Not necessarily. Sites differ in how they load lazy content; if sections are missing, scroll the page or wait for the relevant content before capturing.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
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.

