October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Take a Website Screenshot with Browshot in Python

Use Browshot’s Python client to capture a website as a PNG, with simple and full API workflows, key options, response handling, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Browshot’s Python client, BrowshotClient, to request a website screenshot. For a short, blocking workflow, call simple() and save the returned PNG bytes in binary mode. For explicit status checks or more control over the capture, use the full API: create the screenshot, poll until it finishes or errors, then retrieve the image.

Install and configure Browshot’s Python client

Browshot is a hosted screenshot service; its Python package is a client for the service, not a browser that runs locally. Follow the installation instructions on the official Browshot Python library page, then initialize BrowshotClient with your API key. Keep the key out of source control; load it from an environment variable or another secret store rather than hard-coding it in a committed file.

As an Amazon Associate I earn from qualifying purchases.

Browshot’s documentation warns that running its examples can consume credits. Requests to private and shared instances require a positive balance according to its API documentation; check your account and instance requirements before making a request.

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

Take and save a screenshot with the simple API

The simple client method is the shortest route: it blocks until the capture completes or fails, and returns a response containing a code and PNG data. Check the code before writing the bytes so an error response is not mistaken for an image.

from browshot import BrowshotClient

client = BrowshotClient("YOUR_API_KEY")
result = client.simple("https://example.com", {})

if result.get("code") == 200 and result.get("png"):
    with open("screenshot.png", "wb") as image_file:
        image_file.write(result["png"])
else:
    raise RuntimeError(f"Browshot screenshot failed: {result}")

Replace YOUR_API_KEY with your secret key and the example URL with the page you want to capture. The library documentation also shows a simple_file helper that writes to a named file and reports the path on success; check its current method signature in the library page for the package version you install.

Use the full API when you need status handling or capture options

The full workflow separates creation, status checking, and image retrieval. That makes the capture state explicit and gives you a place to inspect an error before trying to save an image. Browshot’s Python library documents the sequence below. Confirm method signatures against the current library release before using it in production; the published examples include older-style syntax.

import time
from browshot import BrowshotClient

client = BrowshotClient("YOUR_API_KEY")
created = client.screenshot_create("https://example.com", {})
screenshot_id = created["id"]
status = created.get("status")

while status not in ("finished", "error"):
    time.sleep(1)
    info = client.screenshot_info(screenshot_id)
    status = info.get("status")

if status == "error":
    raise RuntimeError(f"Browshot screenshot failed: {info.get('error', info)}")

image_bytes = client.screenshot_thumbnail(screenshot_id)
with open("screenshot.png", "wb") as image_file:
    image_file.write(image_bytes)

The documented API endpoints are /api/v1/screenshot/create, /api/v1/screenshot/info, and /api/v1/screenshot/thumbnail. In the Python client, the corresponding methods are screenshot_create(), screenshot_info(), and screenshot_thumbnail(). If the service returns an error state, inspect the error rather than attempting to treat the result as a PNG.

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

Choose size, cache, delay, and viewport settings

The API documentation describes options that affect what Browshot captures and when:

  • size: screen captures the visible screen-sized area; page captures the full page.
  • cache: reuses a recent screenshot for the same URL and instance. The documentation gives a 24-hour default; set cache=0 to request a fresh capture.
  • delay: waits after page load so JavaScript can run before the screenshot. Check the exact endpoint documentation for accepted limits, which are not consistent across mirrored documentation pages.
  • screen_width and screen_height: set the desktop viewport dimensions.

Other documented options include targeting a CSS selector, sending custom headers, running scripts, and saving rendered HTML. Add options to the dictionary passed to the client method, using the names and values accepted by the endpoint you use. For example, a full-page capture with a fresh result could be expressed as:

options = {
    "size": "page",
    "cache": 0,
}
result = client.simple("https://example.com", options)

Use a delay only when the page needs extra time after load; a longer wait can make capture slower. A cache can avoid repeating a capture when a recent result is acceptable, while disabling cache asks for a fresh screenshot.

Understand responses and avoid saving error payloads

For the simple endpoint, Browshot documents HTTP 200 as a successful PNG response, HTTP 400 as an invalid request, HTTP 404 as a capture failure with an explanatory X-Error header, and HTTP 302 as a request still in progress that should be followed. The full API uses states including in_process, finished, and error. Treat success as an image only after checking the response code or final status. Exact response handling depends on whether you use the Python client or call an endpoint directly.

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

Troubleshoot common Browshot screenshot problems

  • Invalid request or HTTP 400: check that the URL and option names and values are valid for the endpoint. Consult the API documentation for supported parameters.
  • Capture failure or HTTP 404: read the X-Error header where available. The target page may be inaccessible to the capture service, or the request may have failed; do not write the error response as a PNG.
  • The request is still running: a 302 from the simple endpoint indicates an in-progress request to follow. With the full API, poll screenshot_info() until the state is finished or error.
  • Insufficient credits: check the account balance and instance requirements. Browshot’s Python documentation warns its examples may cost credits, and the API documentation says private and shared instance requests require a positive balance.
  • Blank or partially rendered content: check whether the page relies on JavaScript or delayed content. Try an appropriate delay, confirm the target is reachable, and choose page rather than screen if you need the full page.
  • Python example does not match your installed package: the library page contains older-style sample syntax in places. Check the current package documentation for the method signatures supported by your release.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Automate interactions before capturing

If a page requires actions before it can be captured, Browshot documents an automation steps argument. Its login guide describes actions such as typing, clicking, running JavaScript, sleeping, navigating, and taking a screenshot, with CSS selectors for targeting elements. This is more involved than a simple URL capture; use it when the page genuinely requires a sequence of browser interactions. See Browshot’s login automation guide for the documented flow.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF. For example, using cURL:

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

See the ScreenshotNeo documentation for API options. It accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, 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 identify the page verdict and billing status in headers. Its MCP server provides 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 screenshots. Sign up for ScreenshotNeo free.

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

Frequently Asked Questions

Should I use Browshot’s simple method or the full API?

Use simple() for a compact blocking capture; use the full create, status, and retrieval workflow when you need explicit state handling or greater control.

Does this Python code run the browser on my computer?

No. Browshot is a hosted screenshot service, and its Python library sends requests to that service.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.