The easiest way to take a screenshot of a webpage in Python is with Playwright. Install Playwright, open the URL, and call page.screenshot(). Use full_page=True to capture the entire page:
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", full_page=True) browser.close()That is the modern answer for most Python webpage screenshot tasks. You can still use Selenium if it is already in your stack, or pyppeteer if you maintain an older script, but Playwright is the best default choice today.
However, if you do not want to manage and scale browsers yourself, or deal with blocking banners, ads, and other screenshot edge cases, consider using the ScreenshotOne API. It handles these issues and more.
Overview
Playwright is the best library to automate website screenshots in Python today. It is easy to install, actively maintained, and supports full-page screenshots without extra work.
But if you have a few minutes and want to examine all the options to take screenshots of web pages in Python, you can use the following:
- Playwright, a modern browser automation library for screenshots, testing, scraping, and PDF generation.
- An old but battle-tested automation testing framework like Selenium with a web driver of choice.
- pyppeteer, although not maintained and outdated, is still a usable Python port of the JavaScript headless Chrome/Chromium browser automation library. It is also one of the ways to screenshot a webpage without Selenium.
- You can use any URL to screenshot API to quickly start without managing browsers and get useful automation features out of the box.
Let’s quickly give an example for each option and assess which one is better to use and when.
| Option | Best for |
|---|---|
| Playwright | Local scripts, automated tests, and full-page screenshots. |
| Selenium | Existing Selenium test suites and cross-browser automation. |
| pyppeteer | Maintaining legacy Puppeteer-style Python scripts. |
| ScreenshotOne API | Production screenshots, scale, queues, retries, and managed browsers. |
Playwright in Python
Playwright is specifically designed to meet the requirements of end-to-end testing, but it is also a practical tool for screenshot automation. It supports Chromium, WebKit, and Firefox, and can capture full-page screenshots natively. It is one of the ways if you render screenshots without Selenium.
Playwright offers support for contemporary rendering engines, such as Chromium, WebKit, and Firefox. It works across Windows, Linux, and macOS, whether locally or on continuous integration (CI) systems, and supports both headless and headed modes with native mobile emulation.
It is a powerful library and it can do mostly everything that a browser can do:
- Crawl a single-page application or generate server-side rendered content.
- Take screenshots and create PDF documents of web pages.
- Automate tasks such as form submission, user interface testing, and keyboard input.
- Set up an automated testing environment using current JavaScript and browser capabilities.
- Record a timeline trace of your website to troubleshoot performance issues.
- Automate testing of Chrome extensions.
But let’s get back to screenshots and check how easy it is to do it with Playwright.
First, install it:
pip install playwrightplaywright installThen take a screenshot:
from playwright.sync_api import sync_playwright
def run(playwright): # launch the browser browser = playwright.chromium.launch() # open a new browser page page = browser.new_page() # navigate to the website page.goto('https://example.com') # take a full-page screenshot page.screenshot(path='example.png', full_page=True) # always close the browser browser.close()
with sync_playwright() as playwright: run(playwright)That’s how simple it is:

If you want to screenshot webpages without Selenium, Playwright is your best choice.
Python full-page screenshot
Playwright can capture a full-page screenshot with the full_page=True option:
from playwright.sync_api import sync_playwright
with sync_playwright() as p: browser = p.chromium.launch() page = browser.new_page(viewport={"width": 1280, "height": 720}) page.goto("https://example.com", wait_until="networkidle") page.screenshot(path="full-page.png", full_page=True) browser.close()Set the viewport explicitly when the rendered layout matters. Many responsive websites show different navigation, typography, and content at different viewport sizes.
If you do not want to use Selenium, use Playwright. It does not require a separate browser driver like chromedriver, and it provides a cleaner screenshot API:
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="without-selenium.png") browser.close()For new projects, Playwright is usually a better fit than pyppeteer because it is actively maintained and supports Chromium, WebKit, and Firefox.
Selenium in Python
Use Selenium for rendering screenshots in Python if you already have that library in your stack. Otherwise, if the goal is to render screenshots only, go with Playwright. Prefer Playwright to Selenium for new testing projects also, since it is actively developed and supports assertions and almost all modern browsers.
Selenium is a library for automating web browsers. It allows you to control a web browser, such as Google Chrome, Firefox, or Safari, from Python.
Selenium provides a way to write scripts in Python that can interact with web pages in a way that simulates a user interacting with the web page through a web browser. It is useful for a variety of tasks, such as testing web applications, automating repetitive tasks, taking screenshots, and web scraping.
Selenium requires a web driver to control a web browser through Python. Some popular web drivers include chromedriver for Google Chrome, geckodriver for Mozilla Firefox, and safaridriver for Safari.
Install Selenium and your driver of choice using pip:
pip install seleniumpip install chromedriver # or geckodriver, or safaridriverAnd now let’s write a simple script to take a screenshot in Python:
from selenium import webdriver
# 1. create a web driver instancedriver = webdriver.Chrome()
# 2. navigate to the websitedriver.get("https://magician.design/")
# 3. save a screenshot of the current pagedriver.save_screenshot("magician.design.png")
# 4. close the web driverdriver.quit()The result is:

Use Selenium if you want to take screenshots from a different browser, but keep in mind that its screenshot capabilities are minimal. If you are OK with using Chrome or Chromium and don’t care about other browsers but need a powerful library to take screenshots, check out pyppeteer.
pyppeteer
The pyppeteer library is outdated and not maintained anymore. For simple legacy use cases you might still use it, but consider using Playwright instead.
pyppeteer is a Python port of the JavaScript (headless) Chrome/Chromium browser automation library called Puppeteer.
Install with pip from PyPI (pyppeteer requires Python >= 3.6):
pip install pyppeteerLet’s open a website and take a screenshot of it:
import asynciofrom pyppeteer import launch
async def main(): browser = await launch() page = await browser.newPage() await page.goto('https://softstart.app/') await page.screenshot({'path': 'softstart.png'}) await browser.close()
asyncio.get_event_loop().run_until_complete(main())The screenshot is stored at softstart.png. That’s it and that’s how simple it is:

URL to Screenshot API
One of the most significant downsides of taking screenshots with Selenium, pyppeteer or even Playwright is handling infrastructure and taking care of browsers. They are resource intensive. You might encounter crashes, memory leaks, and high levels of CPU consumption.
So, if you need to take only a few screenshots periodically, I would go with Selenium, pyppeteer or Playwright. But if you need scale or don’t want to deal with infrastructure issues, consider using our ScreenshotOne API—an URL to screenshot API.
Use Playwright when you need a local script or test automation. Use a screenshot API when screenshots are part of production infrastructure and you need retries, browser maintenance, blocking banners, proxies, queues, or predictable rendering at scale.
It is free to get started and supports various options—like removing chat widgets, blocking cookie banners, rendering in dark mode, and even animations.
Sign up to get your API access and secret key, and let’s try ScreenshotOne’s official SDK for Python:
pip install screenshotoneAnd:
import shutilfrom screenshotone import Client, TakeOptions
# create API clientclient = Client('<your access key>', '<your secret key>')
# set up optionsoptions = (TakeOptions.url('https://screenshotone.com') .format("png") .viewport_width(1024) .viewport_height(768) .block_cookie_banners(True) .block_chats(True))
# or render a screenshot and download the image as streamimage = client.take(options)
# store the screenshot the example.png filewith open('screenshotone.png', 'wb') as result_file: shutil.copyfileobj(image, result_file)That’s it. The result is:

That’s how simple it was!
If you have any questions, please reach out to support@screenshotone.com and we are happy to help with screenshot automation even if you are not a ScreenshotOne customer and don’t plan to be.
Common problems when screenshotting webpages in Python
You might encounter a few issues while using Playwright, Selenium, or any other browser automation library. Here are the most common ones:
- Blank screenshots: wait until the page loads before taking a screenshot. In Playwright, try
page.goto(url, wait_until="networkidle")or wait for a specific selector withpage.wait_for_selector(). - Lazy-loaded content is missing: scroll the page or wait for the content that should appear before taking the screenshot.
- Cookie banners hide the page: close them with browser automation, block them with custom rules, or use a screenshot API that can block cookie banners.
- Chat widgets cover important content: hide them with CSS, block their scripts, or use a managed screenshot API that supports blocking chat widgets.
- The screenshot has the wrong layout: set a fixed viewport size before opening the page.
- Full-page screenshots are too tall or unstable: test the page at a realistic viewport and avoid infinite-scroll pages unless you control the scroll behavior.
- Login-required pages fail: log in first, reuse a browser context with saved cookies, and never hardcode credentials in source code.
Summary
I would recommend using Selenium only if you are already using it. But if you need screenshots using Python, the best options are to use Playwright or a screenshot API.
For local scripts and tests, I would choose Playwright. If you need to take screenshots at scale and don’t want to deal with browser infrastructure and corner cases, then give a try to a URL to screenshot API like ScreenshotOne.
I hope I helped you a little bit to choose the best Python library to take screenshots and have a nice day!
Frequently Asked Questions
If you read the article, but still have questions. Please, check the most frequently asked. And if you still have questions, feel free reach out at support@screenshotone.com.
What is the best Python library for taking webpage screenshots?
Playwright is the best default choice for taking webpage screenshots in Python today. It is actively maintained, supports Chromium, WebKit, and Firefox, and can capture full-page screenshots with page.screenshot(full_page=True).
Can I take a screenshot of a webpage in Python without Selenium?
Yes. Use Playwright if you want to take webpage screenshots without Selenium. It does not require a separate browser driver like chromedriver and provides a clean screenshot API for normal and full-page screenshots.
What is the difference between Selenium, pyppeteer, and Playwright?
Selenium is useful if you already use it for browser automation or testing. pyppeteer is an older Python port of Puppeteer and is no longer the best choice for new projects. Playwright is the modern default for Python webpage screenshots because it is actively maintained and supports multiple browser engines.
How do I take a full-page screenshot in Python?
With Playwright, call page.screenshot(path='screenshot.png', full_page=True). Set the viewport size first if the page has a responsive layout and wait for the page or target selector before capturing.
When should I use a screenshot API instead of Playwright?
Use Playwright for local scripts and tests. Use a screenshot API like ScreenshotOne when screenshots are part of production infrastructure and you need managed browsers, retries, queues, proxy support, blocking cookie banners or ads, and predictable rendering at scale.