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

The most reliable current way to save a webpage as an image in Python is to render it in a real browser with Playwright, then call page.screenshot(). Use a normal screenshot for the visible viewport, full_page=True for the complete scrollable document, or a locator screenshot for one component. The examples below save PNG, JPEG, and WebP files, show how to capture bytes in memory, and cover the waits and failure cases that make automated captures dependable.

What you need before taking a screenshot

  • Python 3 and a virtual environment for the project.
  • Playwright for Python, plus its browser binary.
  • A reachable webpage URL. Private pages may also require cookies, headers, or a login flow.
  • A writable output directory if you use the path option.

Install the package and browser once in your environment:

python -m pip install playwright
python -m playwright install

The second command downloads the browser used by Playwright. In a deployment image, run it during the image build rather than on every request.

A minimal Python webpage screenshot

This synchronous example opens a page, waits for navigation to complete, writes a PNG, and closes the browser even if capture fails.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
  • Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
  • Built-In Mic: The built-in microphone lets others hear you clearly during video calls
  • Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works
from pathlib import Path
from playwright.sync_api import sync_playwright

url = "https://example.com"
out = Path("example.png")

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page(viewport={"width": 1440, "height": 900})
    page.goto(url, wait_until="load", timeout=60_000)
    page.screenshot(path=str(out))
    browser.close()

print(f"Saved {out}")

page.screenshot(path="example.png") captures the current viewport. The filename extension determines the format; PNG is the default when no other format is inferred.

Viewport, full-page, and element screenshots

Capture only what is visible

Omit full_page (or leave it false) to capture the viewport. Set the viewport explicitly when repeatable dimensions matter:

page.set_viewport_size({"width": 1280, "height": 800})
page.screenshot(path="viewport.png")

A viewport shot is useful for visual regression tests, responsive-layout checks, and thumbnails. It does not include content below the current scroll position.

Capture the complete scrollable page

page.screenshot(path="whole-page.png", full_page=True)

full_page=True expands the capture to the document’s full scrollable height. Very long pages can produce extremely tall images and large files; for reports or printing, a PDF may be more appropriate. Pages that continuously append content while scrolling can also change during capture, so wait for the content you need before calling the method.

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

Capture one component

Use a locator when the requirement is a header, chart, card, or other element rather than the entire document:

header = page.locator("header.site-header")
header.screenshot(path="header.png")

The locator must resolve to an attached, visible element. A specific selector is safer than a broad tag such as div, which may match several nodes.

Rank #2
Sale
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
  • The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
  • C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
  • The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.

Wait for the page state that matters

Navigation finishing does not guarantee that images, charts, fonts, or client-rendered data are ready. Choose a wait based on the page, rather than adding an arbitrary long sleep.

Wait for a required selector

page.goto(url, wait_until="domcontentloaded", timeout=60_000)
page.locator("main article").wait_for(state="visible", timeout=30_000)
page.screenshot(path="article.png", full_page=True)

Wait for a short, known delay

page.goto(url, wait_until="load", timeout=60_000)
page.wait_for_timeout(2_000)
page.screenshot(path="delayed.png")

A fixed delay is predictable but can be either too short for a slow page or unnecessarily slow for a fast one. Prefer a selector or an application-specific readiness signal when possible.

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.

Wait for network idle cautiously

page.goto(url, wait_until="networkidle", timeout=60_000)
page.screenshot(path="network-idle.png")

Network-idle waiting can hang or be misleading on pages with analytics, polling, advertisements, or WebSockets. Treat it as one option, not a universal definition of “ready.”

Reduce animation for repeatable captures

page.screenshot(
    path="stable.png",
    animations="disabled",
    timeout=30_000,
)

Disabling animations helps prevent a capture from landing between two visual states. The documented screenshot timeout default is 30 seconds; raise it for unusually heavy pages, but still keep a finite limit.

Choose an output format and quality

PNG

page.screenshot(path="page.png")

PNG is lossless and supports transparency. It is a good default for text, interfaces, diagrams, and screenshots that may be edited later.

JPEG

page.screenshot(path="page.jpg", quality=85)

JPEG is usually smaller for photographic content. The quality option applies to JPEG and WebP, not PNG. JPEG cannot preserve a transparent background.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
NexiGo N60 1080P Webcam with Microphone, Software Control & Privacy Cover, USB HD Computer Web Camera, Plug and Play, for Zoom/Skype/Teams, Conferencing and Video Calling
  • 【Full HD 1080P Webcam】Powered by a 1080p FHD two-MP CMOS, the NexiGo N60 Webcam produces exceptionally sharp and clear videos at resolutions up to 1920 x 1080 with 30fps. The 3.6mm glass lens provides a crisp image at fixed distances and is optimized between 19.6 inches to 13 feet, making it ideal for almost any indoor use.
  • 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 8, 10 & 11 / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
  • 【Built-in Noise-Cancelling Microphone】The built-in noise-canceling microphone reduces ambient noise to enhance the sound quality of your video. Great for Zoom / Facetime / Video Calling / OBS / Twitch / Facebook / YouTube / Conferencing / Gaming / Streaming / Recording / Online School.
  • 【USB Webcam with Privacy Protection Cover】The privacy cover blocks the lens when the webcam is not in use. It's perfect to help provide security and peace of mind to anyone, from individuals to large companies. 【Note:】Please contact our support for firmware update if you have noticed any audio delays.
  • 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 10 & 11, Pro / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.

WebP

page.screenshot(path="page.webp", quality=80)

WebP can provide a smaller modern web asset while retaining good visual quality. Confirm that the software receiving the file supports it.

Pixel scale and transparency

page.screenshot(
    path="retina.webp",
    scale="device",
    quality=85,
)
page.screenshot(path="transparent.png", omit_background=True)

scale="css" produces dimensions based on CSS pixels and can reduce high-DPI output. scale="device" uses device pixels for a larger, sharper bitmap. omit_background=True allows transparency where the page supports it; it does not apply to JPEG.

Save to disk or process the image in memory

When you omit path, Playwright returns screenshot bytes. This avoids a temporary file and lets you resize, hash, upload, or return the image from an API.

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://example.com", wait_until="load", timeout=60_000)
    image_bytes = page.screenshot(type="png", full_page=True)
    browser.close()

with open("page.png", "wb") as f:
    f.write(image_bytes)

When using an explicit type, keep it consistent with how you handle the returned bytes. Bytes are useful when a web endpoint should stream the result instead of writing to local storage.

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

Reusable asynchronous version

The async API fits applications that already use asyncio or need to capture several pages without blocking the event loop.

import asyncio
from playwright.async_api import async_playwright

async def save_page(url: str, filename: str) -> None:
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page(viewport={"width": 1440, "height": 900})
        try:
            await page.goto(url, wait_until="load", timeout=60_000)
            await page.screenshot(path=filename, full_page=True, animations="disabled")
        finally:
            await browser.close()

asyncio.run(save_page("https://example.com", "example-full.png"))

Use a separate browser context for different users or cookie sets. Reuse one browser process for a batch, while creating pages or contexts per job, to avoid paying browser startup cost repeatedly.

Rank #4
Sale
EMEET C960 1080P Webcam with Microphone, 2 Mics, 90° FOV, Computer Camera
  • 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
  • Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
  • Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
  • Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
  • High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)

Handling JavaScript, cookies, and private pages

Run setup code before capture

page.goto("https://example.com/dashboard", wait_until="domcontentloaded")
page.add_style_tag(content=".cookie-banner, .chat-widget { display: none !important; }")
page.locator("#dashboard-ready").wait_for(state="visible")
page.screenshot(path="dashboard.png", full_page=True)

Injecting CSS can hide known overlays, but it does not accept consent or perform authentication. For a private site, log in through Playwright and reuse saved authentication state according to your security policy; never hard-code credentials in source control.

Use a browser context for locale or device conditions

context = browser.new_context(
    viewport={"width": 390, "height": 844},
    device_scale_factor=2,
    locale="en-US",
    color_scheme="dark",
)
page = context.new_page()
page.goto("https://example.com", wait_until="load")
page.screenshot(path="mobile-dark.png")
context.close()

Viewport, device scale, locale, and color scheme can materially change the rendered result. Record these settings with the image when captures are used as test artifacts.

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

Common errors and fixes

  • Browser executable is missing: run python -m playwright install (and install the required system dependencies on your Linux image).
  • Timeout during goto: increase the navigation timeout for a slow origin, use wait_until="domcontentloaded", and investigate blocked resources rather than setting an unlimited timeout.
  • Timeout during screenshot: the page or locator may still be unstable. Wait for a concrete selector, disable animations, or increase the finite screenshot timeout.
  • Blank or incomplete image: verify the URL, authentication, viewport, and readiness selector. Lazy-loaded content may require scrolling or a page-specific trigger before capture.
  • Element locator matches nothing: confirm the selector in the rendered DOM and wait for attachment or visibility. If content is inside an iframe, locate the frame first.
  • Unexpected cookie or chat overlay: automate the consent flow where permitted, or hide the known selector with page CSS after confirming that doing so does not change the content you are testing.
  • Huge full-page file: use a viewport or element shot, lower the pixel scale, choose JPEG/WebP, or capture a PDF for paginated output.
  • Missing fonts or images: wait for the relevant elements, check network and CORS errors, and ensure the runtime can reach every asset host.
  • Capture differs between runs: freeze animations, use a fixed viewport and locale, wait for deterministic application state, and control time-dependent data in the test environment.

Performance, reliability, and operating cost

  • Browser startup: launch once and reuse the process for a batch; close contexts and pages promptly.
  • Concurrency: limit simultaneous pages to the CPU and memory available. More workers can increase throughput but also trigger origin rate limits and resource exhaustion.
  • Navigation: use finite timeouts and log URL, status, elapsed time, and the readiness condition for each job.
  • Images: full-page and device-scale captures consume more memory. Set output dimensions deliberately and avoid retaining large byte arrays longer than necessary.
  • Security: treat target URLs as untrusted input, restrict access to internal address ranges in a server-side service, and isolate browser processes when capturing arbitrary sites.
  • Repeatability: pin your Playwright and browser versions in deployment, because browser rendering can change as dependencies change.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you only need a clean image from a URL, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request renders the page and returns PNG, JPEG, WebP, or PDF. Its cleanup steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

See the full parameter list in the ScreenshotNeo documentation. This call saves a WebP directly:

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

Python:

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo also supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDF paper and page options, custom CSS and JavaScript, clicks, selector or network-idle waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

Plan Included shots Price
Free 1,000 per month No card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Yearly billing gives two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to get 1,000 screenshots each month with no card; paid plans start at $5 for 3,000.

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

FAQ

Can Python save a screenshot without opening a visible browser window?

Yes. Playwright launches Chromium headlessly by default, so the script can render and capture pages without displaying a browser window. Use headed mode only when diagnosing a visual or interaction problem.

Best Value
Logitech C920x HD Pro PC Webcam Full 1080p/30fps Video - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • HD lighting adjustment and autofocus: The Logitech webcam automatically fine-tunes the lighting, producing bright, razor-sharp images even in low-light settings. This makes it a great webcam for streaming and an ideal web camera for laptop use
  • Advanced capture software: Easily create and share video content with this Logitech camera that is suitable for use as a desktop computer camera or a monitor webcam
  • Stereo audio with dual mics: Capture natural sound during calls and recorded videos with this 1080p webcam, great as a video conference camera or a computer webcam
  • Full HD 1080p video calling and recording at 30 fps. You'll make a strong impression with this PC webcam that features crisp, clearly detailed, and vibrantly colored video

Why is my full-page image extremely tall?

Full-page mode includes the document’s entire scrollable height. For a more manageable artifact, capture a specific element, use the viewport, reduce scale, or produce a paginated PDF.

Which format should I use for text-heavy screenshots?

PNG is generally the safest choice for crisp text and transparency. Use JPEG or WebP when a smaller file matters and lossy compression is acceptable.

Can I capture a page that requires a login?

Yes, if your automation is authorized: perform the login in Playwright, preserve the authenticated context securely, then wait for a post-login selector before capturing. Do not place credentials in source code or logs.

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

Frequently Asked Questions

Can Python save a screenshot without opening a visible browser window?

Yes. Playwright runs headlessly by default; switch to headed mode only while diagnosing a capture.

Why is my full-page image extremely tall?

Full-page mode includes all scrollable content. Use an element or viewport capture, reduce scale, or create a paginated PDF.

Which format is best for text-heavy screenshots?

PNG is the safest default for crisp text and transparency; WebP or JPEG can reduce file size when lossy compression is acceptable.

Quick Recap

SaleBestseller No. 1
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
Compatible with Nintendo Switch 2’s new GameChat mode; Built-In Mic: The built-in microphone lets others hear you clearly during video calls
$35.90
SaleBestseller No. 2
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black
Compatible with Nintendo Switch 2’s new GameChat mode
$16.89
Bestseller No. 5
Logitech C920x HD Pro PC Webcam Full 1080p/30fps Video - Black
Logitech C920x HD Pro PC Webcam Full 1080p/30fps Video - Black
Compatible with Nintendo Switch 2’s new GameChat mode; Fully compatible with Windows 11
$69.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.

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