October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan 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

Capture Website Screenshots in Python with Playwright and Upload Them to S3

A practical guide to capturing website screenshots with Playwright Python and uploading them to S3 with Boto3, including in-memory uploads and access guidance.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright’s Python API to capture a page as an image, then Boto3 to upload the file or its bytes to an Amazon S3 bucket. A screenshot upload does not make the object public: storage permissions and any sharing policy are separate decisions.

Choose what to capture and how to hand it off

Playwright can capture the visible viewport, the full scrollable page, or one matched element. It can save the image to a path or return image bytes, which you can process in memory or wrap in a readable binary stream for Boto3.

As an Amazon Associate I earn from qualifying purchases.

Need Playwright approach Handoff to S3
Visible viewport page.screenshot(path="website.png") Upload the local filename with upload_file.
Full scrollable page page.screenshot(path="website.png", full_page=True) Upload the local filename with upload_file.
One element page.locator("selector").screenshot() Write returned bytes to a file or pass a readable binary stream to upload_fileobj.
In-memory processing or transfer Call page.screenshot() without a path; it returns bytes. Wrap the bytes in io.BytesIO and use upload_fileobj.

Pick the capture scope and image type that fit the job. For repeatable visual comparisons, control page state and rendering inputs; a screenshot alone does not make a capture a stable visual test.

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

Install the Python dependencies

Install Playwright and Boto3 in the environment that will run the script:

#1 Best Overall
Sandisk 2TB Extreme Portable SSD, Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware, External Solid State Drive, SDSSDE61-2T00-G25
  • Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
  • Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
  • Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
  • Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
  • Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C
python -m pip install playwright boto3
python -m playwright install chromium

The second command installs the Chromium browser Playwright will launch. Run it in each environment where the browser is not already installed.

Capture a full page and upload the file with Boto3

This synchronous example saves a full-page PNG locally, closes the browser, then uploads the resulting file to the named S3 bucket and object key. Replace the example URL, bucket, and key with your values.

from pathlib import Path
import boto3
from playwright.sync_api import sync_playwright

output = Path("website.png")
bucket = "your-bucket"
key = "screenshots/website.png"

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://example.com")
    page.screenshot(path=str(output), full_page=True)
    browser.close()

s3 = boto3.client("s3")
s3.upload_file(str(output), bucket, key)

upload_file takes the local filename, bucket name, and object key. The key is the object’s name in the bucket; a prefix such as screenshots/ is part of that name, not a local directory requirement.

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.
Rank #2
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
  • Solid state performance with up to 800MB/s read speeds in a portable drive. (Based on internal testing; performance may be lower depending on host device, interface, usage conditions and other factors. 1MB=1,000,000 bytes.)
  • Back up your content and memories on a storage solution that fits seamlessly into your mobile lifestyle.
  • Take it with you on your adventures—up to two-meter drop protection means this durable drive can take a beating. (Based on internal testing.)
  • Secure it to your belt loop or backpack for extra peace of mind thanks to the tough rubber hook.
  • From Sandisk, a brand professional photographers trust to take on assignments.

Upload screenshot bytes without a local image file

When you need to transform the image in memory or avoid writing it to disk, omit the screenshot path. Playwright returns bytes; wrap them in a binary file-like object and pass it to Boto3’s upload_fileobj.

import boto3
from io import BytesIO
from playwright.sync_api import sync_playwright

bucket = "your-bucket"
key = "screenshots/website.png"

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

s3 = boto3.client("s3")
s3.upload_fileobj(BytesIO(image_bytes), bucket, key)

upload_fileobj expects a readable file object opened in binary mode. BytesIO provides that interface for the returned bytes. If the object is too large to comfortably hold in memory, prefer the path-based workflow or another design suited to your memory limits.

Capture only one element

Use a locator’s screenshot method when the output should contain one matched element rather than the whole page. The call returns bytes if no path is supplied, so it can use the same BytesIO upload pattern.

Rank #3
SSK Portable SSD 500GB External Solid State Hard Drive USB C Up to 1050MB/s
  • Capacity Display Variance: 500GB external ssd often appears as around 465GB on Windows. MacOS can show full 500 GB capacity. This is binary calculation difference and doesn’t affect SSD hard drive actual physical storage
  • 1050 MB/s Speed: Instantly access to your files with blazing-fast 10Gbps external SSD read up to 1050MB/s and write up to 1000MB/s. LED Light indicates USB SSD instant activity
  • Data Security: Solid state drives S.M.A.R.T. health diagnostics​ and adaptive TRIM optimizing data block management ensures consistent write speeds and extends the longevity of the portable SSD
  • USB-C & USB-A Cable: Both cables featuring rapid USB 3.2 Gen2, this USB SSD effortlessly bridges devices, enabling seamless cross-platform file transfers and backup between computers, smartphones, tablets and iPhone
  • Always Fast: No slowdowns for large file transfers. With SLC caching (25% of current available capacity allocated as high-speed cache), this external SSD delivers steady 10Gbps for transfers within the cache capacity
from io import BytesIO
import boto3
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")
    image_bytes = page.locator("main article").screenshot(type="png")
    browser.close()

boto3.client("s3").upload_fileobj(
    BytesIO(image_bytes),
    "your-bucket",
    "screenshots/article.png",
)

Use a selector that identifies the intended element on the target page. The locator screenshot API also provides options such as image type and animation handling; consult the current Playwright API documentation for the complete option set.

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

Configure AWS identity and bucket access

Create the Boto3 client without embedding access keys in the script. Boto3 uses its configured credential provider chain, so configure the identity in the execution environment and grant it the permissions needed for the specific bucket and object operation. The exact policy depends on your account, organization, deployment environment, and access requirements.

On EC2, an attached IAM role can provide credentials automatically when earlier sources in the provider chain have not supplied them. Use the identity mechanism appropriate to the environment where the script runs rather than copying credentials into source code.

Rank #4
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Boto3’s managed upload methods handle large files by splitting them into smaller chunks and uploading them in parallel. You can pass supported upload options, including metadata, through ExtraArgs; check Boto3’s current documentation for the options supported by the method and transfer configuration you use.

Keep upload permissions separate from public access

Uploading an object does not make it publicly readable. AWS says new buckets, access points, and objects do not allow public access by default, and Block Public Access settings can override policies and ACL permissions that would otherwise allow it. AWS’s Boto3 S3 bucket creation documentation recommends keeping all Block Public Access settings enabled and ACLs disabled for the majority of modern S3 use cases.

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

If an application genuinely needs external readers, decide deliberately how those readers should get access and review the relevant policy and account-level settings. Do not add a public ACL as a routine part of a screenshot upload. For private storage, keep access limited to the identities and services that need the object.

Best Value
Sale
Samsung T7 Portable SSD 1TB Titan Gray, USB 3.2 Gen 2, Up to 1,050MB/s
  • MADE FOR THE MAKERS: Create; Explore; Store; The T7 Portable SSD delivers fast speeds and durable features to back up any endeavor; Build your video editing empire, file your photographs or back up your blogs all in an instant
  • SHARE IDEAS IN A FLASH: Don’t waste a second waiting and spend more time doing; The T7 is embedded with PCIe NVMe technology that brings fast read and write speeds up to 1,050/1,000 MB/s¹, making it almost twice as fast as the T5
  • ALWAYS MAKE THE SAVE: Compact design with massive capacity; With capacities up to 4TB, save exactly what you need to your drive – from large working files to game data and everything in between
  • ADAPTS TO EVERY NEED: Whether using a PC or mobile phone, count on the T7 for extensive compatibility²; It’s a true team player when it comes to heavy-duty application usage or file-saving
  • HI RESOLUTION VIDEO RECORDING: Record Ultra High Resolution (4K 60fs) videos directly onto the T7 Portable SSD with your favorite camera or mobile devices; Supports iPhone 15 Pro Res 4K at 60fps video and more³
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

  • Playwright cannot launch Chromium: install the browser in the runtime environment with python -m playwright install chromium, and ensure the deployment supports the browser’s system dependencies.
  • Navigation or capture fails: verify the target URL is reachable from the machine running the script and inspect Playwright’s exception for navigation or timeout details. Pages that depend on client-side rendering may need an appropriate wait condition before capture; choose one that reflects the page state you need.
  • A full-page capture is unexpectedly long or incomplete: confirm you used full_page=True and that the page has finished rendering the content you expect. Lazy-loaded content may require scrolling or other page-specific handling before capture.
  • upload_file cannot find the screenshot: check that the path passed to it matches the screenshot path and that the capture completed before upload begins.
  • Boto3 reports missing or invalid credentials: configure a supported credential source for the process and confirm it is available in that runtime. Avoid adding literal keys to the script.
  • The upload is denied: check that the configured identity has permission for the intended bucket and object operation, and review any account, bucket, or organization restrictions.
  • The upload succeeds but a browser cannot read the object: success confirms an upload, not public access. Review the intended sharing mechanism and Block Public Access settings instead of assuming the object should be public.

Or skip the browser setup

If your goal is to request a website screenshot rather than manage a browser runtime, ScreenshotNeo provides a screenshot API and MCP server. For API options and setup, see the ScreenshotNeo documentation.

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

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; these steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server lets AI agents use screenshot tools. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Can I upload a Playwright screenshot directly to S3 without saving it locally?

Yes. Call page.screenshot() without a path, wrap the returned bytes in io.BytesIO, and pass that readable binary stream to upload_fileobj.

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

Does uploading a screenshot make the S3 object public?

No. Uploading and public access are separate. New S3 buckets, access points, and objects are non-public by default, and Block Public Access can override public policies and ACLs.

Quick Recap

Bestseller No. 2
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
From Sandisk, a brand professional photographers trust to take on assignments.
$188.90
SaleBestseller No. 4
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$129.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.

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
Crashes, No Sound, or Screen Glitches?Free driver scan

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.