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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Use Playwright to open a URL in a real browser and save a screenshot with Python. Its page.screenshot() method can capture the current view, the full scrollable page, or a specific element. The guide below uses Playwright’s synchronous API; Selenium is a documented alternative for saving the current window.

Capture a website screenshot with Playwright

Install Playwright and its browser according to the official Python getting-started guide. Then launch a browser, create a page, navigate to the target URL and save the screenshot. This synchronous example saves a PNG:

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")
    page.screenshot(path="screenshot.png")
    browser.close()

Replace https://example.com with the URL you want to capture. The sample uses Playwright’s synchronous Python API; Playwright also documents an asynchronous form. The essential capture call is page.screenshot(path="screenshot.png"). See the Playwright Page API for navigation and screenshot controls.

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.

Choose what to capture

Current browser view

The default screenshot captures the page’s current view. Its contents depend on the page state when the script takes the screenshot.

Full scrollable page

Set full_page=True to capture the full scrollable page as one tall image:

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

One element

Use a locator’s screenshot method to save a matching element, such as a header, rather than the whole page:

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

The selector .header is a CSS class selector; change it to match the element on your page. Playwright documents page, full-page and locator-level screenshots in its Python screenshots guide.

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

Save an image or work with its bytes

Providing path writes the screenshot to a file. If you omit the path, Playwright’s screenshot method returns image bytes, which you can process in Python or pass to another service. The Page API also documents controls for image type and scale.

Use Selenium if it fits your existing workflow

Selenium’s Python WebDriver API provides driver.save_screenshot(filename) to save the current window as a PNG. Its API also documents access to screenshot data as PNG bytes or Base64 text. The documented methods cited here establish current-window capture; Playwright’s cited guide additionally documents full-page and locator-level captures. Choose based on the capture scope and the browser-automation library you already use, not an assumed speed or quality advantage.

For an example that navigates to a URL, saves a screenshot and quits the driver, see Selenium’s guide to working with windows and tabs. The Selenium Python WebDriver API documents the screenshot methods.

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

Or skip the browser setup:

For a direct screenshot request from Python, ScreenshotNeo accepts a URL and returns a screenshot. Its API supports PNG, JPEG or WebP output; see the ScreenshotNeo documentation for the available request parameters.

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

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

Get an API key from ScreenshotNeo. The request shown saves the response body as shot.webp; use the documentation to select the output format and other capture options.

Account for page state

Browser automation captures the rendered page state reached by the script. A navigation call does not guarantee that every site’s dynamic content has finished loading, and some pages may require authentication or other setup. For pages that need additional preparation, consult the Playwright screenshot and Page API documentation for supported capture controls.

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.