The most reliable way to screenshot a website from Python is Playwright. It drives a real Chromium, waits for the page properly, and captures the whole scrollable page in one call. Install it and download its browser once:
Save this as screenshot.py and run python screenshot.py https://example.com:
It writes page.png. full_page=True captures the entire scrollable page rather than the 1280 by 800 window, and wait_until="networkidle" waits until the page has made no network requests for half a second, which covers most pages that fetch their content with JavaScript after they load.
Every script in this guide was run with Playwright 1.65 for Python against live pages and against a small test site built to reproduce each problem described below.
Screenshot one element
Point a locator at the element and screenshot the locator. The image is cropped to the element's box:
Any CSS selector works in place of p, such as #pricing or table.results. .first takes the first match; without it, Playwright refuses to screenshot a locator that matches several elements.
Screenshot at phone size
Responsive sites can send phones different markup, not just a narrower layout, so emulate the whole device rather than shrinking the window. Playwright ships device presets:
The iPhone 13 preset sets a 390 by 664 viewport at a device scale factor of 3, a mobile user agent and touch support, so phone.png comes out 1170 by 1992 pixels.
Images missing from a full-page screenshot
Most sites load images only when they scroll into view, either with loading="lazy" or with a script that watches the scroll position. A full-page screenshot never scrolls, so those images are never requested. On a test page with 12 lazy-loaded images, the first script in this guide captured none of them.
Scroll through the page first, then wait for the images that scrolling started:
This captured all 12 images, including on a version of the page where each image took 1.5 seconds to arrive. The explicit image wait matters: calling page.wait_for_load_state("networkidle") after scrolling looks equivalent, but the page already reached that state before the scroll, so it returned immediately, with 6 of the 12 slow images still loading.
Blank areas, fade-ins and cookie banners
Three more things spoil automated screenshots:
- Content that arrives late. A dashboard or single-page app may render nothing until its own API call returns.
networkidleusually covers it, but it never fires on a page that keeps a connection open, such as a chat widget or a live feed: on such a test page it timed out. Playwright's own documentation marksnetworkidleas discouraged for this reason. Waiting for an element you know appears once the content is there is faster and does not hang. - Animations. A hero that fades in over a second is still invisible when the page is otherwise ready. With the default settings, a fade-in test page came out blank.
- Overlays. Cookie banners and chat launchers often appear a moment after load, so waiting longer makes them more likely to be in the picture, not less.
This version handles all three:
Run it as python screenshot.py https://example.com/app "#dashboard h1" "#cookie-banner, .chat-launcher". animations="disabled" fast-forwards finite CSS animations and transitions to their end state, and style applies the CSS only while the screenshot is taken. On the test pages, the faded hero appeared in full and the banner was gone.
Screenshot many URLs
Start the browser once and reuse the page, so a slow or broken URL costs one failure, not the whole run:
Without running a browser
Everything above runs Chromium on your machine or server: a browser to install and keep updated, memory to budget, and fonts that may render differently from a desktop. If you would rather make an HTTP call, the domscout screenshot API runs the same kind of capture, including the lazy-image scroll and the overlay hiding:
A viewport capture costs 1 credit; fullPage, lazyScroll or both add 1, so this request costs 2. Full-page capture needs the Pro plan or above. A full-page capture with lazyScroll is the heaviest kind of request, so if one answers 504, send it again with "async": true and collect the result as a job. To try a single page without code or an account, use the free website screenshot tool.
Next steps
- The screenshot API guide covers every option, from viewports to PDFs.
- Using Node instead? See full-page screenshots with Puppeteer.
- If a screenshot still comes out blank, five causes and their fixes applies to Playwright too.
- The screenshot API overview lists formats and plans on one page, and the API documentation every field and error code.