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.

Use Python with Playwright to open a real browser, navigate to a page, wait for the content you need, and save a screenshot. Run that script locally for one-off or developer-machine captures; package it as an Apify Actor when you need cloud runs, structured input, stored results, API invocation, integrations, or schedules. This guide builds the local capture first, then shows how to adapt the workflow for Apify.

How the screenshot workflow fits together

A browser screenshot is only as reliable as the state of the page when the capture starts. The basic workflow is:

  1. Choose a URL and a consistent browser viewport.
  2. Navigate with Playwright and wait for the page state that matters.
  3. Capture either the visible viewport or the full page.
  4. Save the image locally or expose it through platform storage.
  5. For recurring or remote jobs, run the same logic in an Apify Actor.

Playwright is useful when a site renders content with JavaScript or needs browser interaction. Its Python API supports screenshot capture and options such as format, clipping, and quality; consult the Playwright screenshot documentation for the installed version’s exact options. Apify’s Python SDK is the official library for creating Python Actors, and its documentation describes browser automation with Playwright or Selenium as supported capabilities: Apify SDK for Python.

Install Python, Playwright, and a browser

For local work, create an isolated Python environment, install Playwright, and install a browser binary. The commands below use Python’s standard virtual-environment tooling and the Playwright package:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Create and activate an environment:

    python -m venv .venv

    On macOS or Linux, activate it with source .venv/bin/activate. On Windows PowerShell, use .venvScriptsActivate.ps1.

  2. Install Playwright:

    python -m pip install playwright

  3. Install Chromium for Playwright:

    python -m playwright install chromium

If the browser installation needs operating-system libraries on a Linux host, follow Playwright’s installation guidance for that host. Apify’s supported Actor image already includes Playwright and browsers for the relevant template; local execution still requires completing Playwright setup. See Apify’s Python guide for the platform-oriented workflow.

Capture a full-page screenshot with Python and Playwright

This async example accepts a URL, uses a fixed viewport for repeatability, waits for network activity to settle, and saves a full-page PNG. Save it as capture.py:

import asyncio
import sys
from pathlib import Path
from playwright.async_api import async_playwright

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

async def capture(url: str, output: str = "page.png") -> None:
output_path = Path(output)
output_path.parent.mkdir(parents=True, exist_ok=True)

async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
try:
page = await browser.new_page(viewport={"width": 1440, "height": 900})
await page.goto(url, wait_until="networkidle", timeout=60000)
await page.screenshot(path=str(output_path), full_page=True)
finally:
await browser.close()

if __name__ == "__main__":
if len(sys.argv) < 2:
raise SystemExit("Usage: python capture.py URL [OUTPUT]")
asyncio.run(capture(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "page.png"))

Run it with python capture.py https://example.com output/example.png. The expected result is a PNG at the chosen path. This is an implementation pattern, not a guarantee that every site will be ready at networkidle; pages that keep long-lived connections open or load important content later may need a different readiness condition.

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

Viewport capture or full-page capture?

  • Viewport: omit full_page=True when the image should show only the visible browser area. This is often preferable for visual checks of a fixed region.
  • Full page: use full_page=True for long documentation pages or archival captures. Tall pages can produce large images and take longer to render and store.
  • Clipped region: use Playwright’s screenshot clipping options when only a defined rectangle is relevant; consult the version-specific API reference for coordinates and constraints.

Wait for meaningful page readiness

Do not add an arbitrary long sleep as the default readiness strategy. If a page’s key content appears asynchronously, wait for a specific selector or another observable state that signifies the content is ready. Playwright provides browser interaction and auto-waiting capabilities, but your capture still needs an application-specific readiness signal. For example, replace the navigation wait with a selector wait when the page has a known content element:

await page.goto(url, wait_until="domcontentloaded", timeout=60000)
await page.locator("main article").wait_for(state="visible", timeout=30000)
await page.screenshot(path=str(output_path), full_page=True)

Choose a selector that actually represents the content to capture; a generic page shell may appear before the data you care about.

Choose screenshot options deliberately

Playwright’s screenshot API supports options for image format, quality, clipping, and full-page capture. The appropriate combination depends on how the image will be used:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • PNG: a sensible choice when you want a lossless image. It is the default format when saving a path with a PNG extension.
  • JPEG: useful when a smaller lossy image is acceptable; set a quality value supported by the installed Playwright version.
  • Viewport dimensions: set these explicitly so repeated captures use the same layout conditions.
  • Full-page option: enable it only when content below the initial viewport matters.
  • Clip: capture a specific rectangle when a full viewport or page would include irrelevant content.

For visual comparisons, record the viewport and capture settings alongside the image. A changed viewport can alter responsive layout, text wrapping, and lazy loading, so two screenshots with different dimensions may not be meaningfully comparable.

Package the capture as an Apify Actor

An Apify Actor turns the script into a cloud job with structured JSON input and platform output. Apify describes the model as an Actor receiving structured input, doing a job such as browser automation, and storing results on the platform. The platform is useful when the capture must run away from your machine or connect to storage, API calls, schedules, or integrations. See Apify Actors documentation.

Define structured input

Start with an input object such as:

{
"url": "https://example.com",
"full_page": true,
"image_type": "png",
"viewport_width": 1440,
"viewport_height": 900,
"output_name": "example.png"
}

Validate required values before launching a browser: require a valid URL, allow only formats the implementation handles, check that viewport dimensions are positive, and give the output a safe filename. Actors consume structured JSON input, so a stable input schema makes manual runs and API calls easier to repeat.

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

Adapt the local script to the Actor lifecycle

In an Actor, read the input through the Apify SDK, use the browser available in the supported runtime, and save or push the resulting image to platform storage. Return useful metadata with the stored image reference, such as the URL, capture time, viewport, full-page setting, and output path. Do not treat a local filesystem path as a durable public result unless the Actor explicitly stores or exposes the file through Apify storage.

The SDK guide documents the Python Actor lifecycle and packaging model. Follow the Actor template and SDK conventions for initialization, input retrieval, and storage rather than copying local-only setup commands into the cloud container: Apify Python SDK documentation.

Invoke the Actor and retrieve its result

Once deployed, invoke the Actor through Apify’s API or console, pass the JSON input, inspect the run, and read the stored output. The official Python Actor example shows invocation with ApifyClient and iteration over dataset items: Apify Python client quick start. For an image file, use the storage record or file reference your Actor produces; a dataset item is useful for metadata and links, but it is not itself the image unless you store the image content there intentionally.

Schedule the job

After the Actor produces a reliable result for a manual run, configure a schedule in Apify or invoke it from another system on the desired cadence. Apify supports manual starts, API calls, schedules, and integrations. Keep the output naming scheme and metadata clear enough that downstream jobs can distinguish captures over time.

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.

Local Playwright or an Apify Actor?

Consideration Local Playwright script Apify Actor
Setup Install Python dependencies and browser binaries on the machine or host running the script. The supported Apify image includes Playwright and browsers for the relevant Actor template.
Execution Runs on your computer or infrastructure you choose. Runs as a cloud Actor with structured input and platform output.
Integration You connect your own scheduler and storage. API calls, storage, schedules, and integrations are platform workflows.
Control You directly manage the runtime and files. Apify supplies a managed runtime and platform services for Actors.
Scaling You provision and maintain the infrastructure needed for your workload. Apify is designed to run and scale Actors on its platform; actual resource behavior depends on the Actor and run configuration.

For a few captures during development, local execution keeps the moving parts visible. Choose an Actor when cloud execution, repeatable input, platform storage, API invocation, or scheduling is part of the requirement—not simply because a screenshot is involved.

Reliability, performance, and permission checks

  • Keep the viewport deterministic. Set dimensions explicitly and include them in the output metadata.
  • Use a real readiness condition. A selector or page state tied to the content is usually more dependable than a fixed delay. Some sites never become network-idle, so test readiness behavior against the target page.
  • Set timeouts and handle failures. Production jobs should bound navigation and selector waits, record failures, and retry only transient problems. Avoid an unbounded retry loop that repeatedly loads a broken or blocked page.
  • Plan for large captures. Full-page screenshots of very tall pages can consume more time, memory, and storage than viewport images. Capture only the region needed when page length is not important.
  • Consider dynamic elements. Cookie banners, animations, ads, and lazy-loaded sections are site-specific. Decide whether to accept, wait for, hide, or otherwise handle them before comparing captures.
  • Respect access rules. Follow the site’s terms, robots directives, authentication boundaries, and privacy requirements. Browser automation capability is not permission to capture a particular site.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common screenshot failures

Playwright reports that Chromium is missing

The Python package is installed, but its browser binary may not be. Run python -m playwright install chromium in the active environment. On a local Linux system, install any required operating-system dependencies using Playwright’s platform instructions. Apify’s supported image includes browsers for the applicable Actor template.

The screenshot is blank or misses JavaScript content

The page may have been captured before its content rendered, or the site may have returned a challenge or error page. Wait for a target-specific selector or state, inspect the page response and visible content, and avoid assuming that successful navigation means the desired content loaded.

Navigation times out

Some pages keep connections open or load slowly. Use a finite timeout, choose a readiness event appropriate to the site, and then wait for the content selector you need. Do not simply raise timeouts indefinitely; record the URL and failure so you can distinguish slow pages from blocked or unavailable ones.

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

The full-page image is unexpectedly large

Full-page mode includes content beyond the initial viewport. Switch to viewport or clipping capture if the page length is not needed, or select a compressed image format when its quality trade-off is acceptable.

The cloud run cannot find the local output file

Files inside an Actor’s runtime are not automatically a permanent result. Store or expose the image using the Actor’s configured storage workflow, and return its storage reference with metadata.

Or skip the browser setup

For a one-request capture without installing Playwright or managing a browser, ScreenshotNeo accepts a URL and returns an image or PDF. 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://example.com -o shot.webp

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

ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include page-verdict and billing headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Learn about ScreenshotNeo or sign up free for 1,000 screenshots a month with no card.

Frequently Asked Questions

Can I automate screenshots of JavaScript-rendered pages with Python?

Yes. Playwright runs a browser, so you can wait for a page-specific selector or state before calling its screenshot method.

Does Apify make screenshots recurring automatically?

An Actor can be run manually, through its API, or on a schedule; scheduling is configured as part of the platform workflow.

Should I use a dataset to store the screenshot image?

Use the Actor’s storage workflow for the image file and return a storage reference and capture metadata; dataset records can carry that metadata or a link.

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.