Recommended Free Tools
To convert HTML to an image with Python and Selenium, open the HTML in a browser controlled by WebDriver and save a screenshot. The example below captures the browser’s current window as a PNG; use a browser-specific full-page method when you need the whole document rather than the visible viewport.
Set up Selenium and a browser
Current Selenium Python documentation supports Python 3.10 and later and recommends installing or upgrading the package with pip install -U selenium. Selenium automates a browser; it still needs a compatible browser, but Selenium Manager handles browser-driver setup in most supported environments when you create a WebDriver. Check the official Selenium documentation for current support and environment requirements, since package and browser support can change.
For a local script, you do not need Selenium Server. Remote WebDriver use requires Selenium Grid. The official docs list Chrome, Edge, Firefox, Safari, WebKitGTK, and WPEWebKit among supported browsers; availability depends on your runtime and platform.
- Install Python 3.10 or later.
- Install Selenium:
python -m pip install -U selenium. - Install or make available a supported browser. In most supported environments, Selenium Manager configures the driver when WebDriver starts.
Capture a local HTML file as a PNG
Save your markup as page.html, then run this script from a Python environment where Selenium and Chrome are available:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
from pathlib import Path
from selenium import webdriver
html_path = Path("page.html").resolve()
output_path = Path("output.png").resolve()
driver = webdriver.Chrome()
try:
driver.get(html_path.as_uri())
saved = driver.save_screenshot(str(output_path))
if not saved:
raise OSError(f"Could not save screenshot: {output_path}")
finally:
driver.quit()
Path.as_uri() creates a file URL for the resolved local path. save_screenshot() writes the current browser window as a PNG and returns a boolean; the check turns a failed save into a clear error. The finally block closes the browser even if navigation or capture raises an exception.
Capture a remote page instead
For a public URL, replace the local-file navigation line with driver.get("https://example.com"). The rest of the capture and cleanup code stays the same. The image shows the page as rendered in that browser session, including its CSS, fonts, images, and JavaScript state.
Choose the capture area and dimensions
Visible browser window
save_screenshot(path) captures the current window, not automatically the entire document. Set an explicit viewport size when the output must have predictable dimensions:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
driver.set_window_size(1280, 900)
driver.get(html_path.as_uri())
driver.save_screenshot(str(output_path))
Set the size before capture; setting it before navigation can also help pages lay themselves out at the intended width. Window dimensions alone do not control every visual variable: device scale, browser zoom, scrollbars, available fonts, and image loading can affect the rendered result. Verify those conditions in the target runtime if exact visual consistency matters.
One element
When the desired output is a component rather than the viewport, locate the element and use Selenium’s element screenshot method:
from selenium.webdriver.common.by import By
element = driver.find_element(By.CSS_SELECTOR, ".card")
element.screenshot("card.png")
Replace .card with a selector in your page. Element capture is useful for a component image; confirm that the element is visible and that its content has finished rendering before taking the screenshot. See the Selenium WebDriver interactions documentation for element interaction and capture details.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Entire document
Full-document capture is not interchangeable with a viewport screenshot and is not exposed identically across browser drivers. Selenium’s Firefox Python API documents driver.get_full_page_screenshot_as_file(path) and driver.save_full_page_screenshot(path). These are Firefox-specific APIs in the documented bindings; do not assume they work unchanged with Chrome or every WebDriver implementation. Check the API for your chosen browser and test the result against the browser version you deploy.
For the ordinary viewport capture APIs, Selenium also documents get_screenshot_as_file(filename), which writes a PNG to a file, get_screenshot_as_png() for PNG bytes, and base64 screenshot methods for embedding. Consult the current Python WebDriver API for exact signatures.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Wait for the page to be ready
A screenshot records the browser state at capture time. If JavaScript, fonts, images, or other assets are still loading, the saved image may be incomplete. Prefer waiting for a meaningful page condition, such as the presence of a result element or an application-ready indicator, rather than relying only on a fixed sleep. A fixed delay can be too short on a slow run and unnecessarily long on a fast one.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
- For dynamic content, identify a selector or application signal that means the relevant content is ready.
- For images, check that the images needed in the output have loaded before capture.
- For visual consistency, run with the same browser, viewport, fonts, zoom, and device-scale conditions as the intended output.
Troubleshoot common failures
| Symptom | Likely cause | What to check or do |
|---|---|---|
| WebDriver fails to start | The browser is missing, incompatible, or unavailable to Selenium Manager in the runtime. | Confirm a supported browser is installed and usable. Review Selenium’s current setup guidance; use manual browser-driver setup if Selenium Manager does not suit the environment. |
| The screenshot is blank or missing content | The page may not have loaded its dynamic content, fonts, or images before capture. | Wait for a meaningful ready condition and verify the page state in the same browser session before saving. |
| The output has the wrong size or crop | The script captured the viewport rather than the full document, or the window dimensions differ from the intended viewport. | Set an explicit window size. If you need the full document, use a full-page method documented for your browser driver. |
save_screenshot() reports failure |
The file could not be saved to the requested path. | Use an absolute output path and confirm the destination directory is writable; check the boolean return value. |
| Browser processes remain after an error | The driver was not closed when an exception occurred. | Put browser work in a try block and call driver.quit() in finally. |
Consider Playwright if the project is not tied to Selenium
Playwright is another documented Python browser-automation option. Its library guide covers Chromium, Firefox, and WebKit, and its screenshot guide shows saving an image with page.screenshot(path="screenshot.png"); browsers run headless by default. The documentation establishes that it can capture screenshots, not that it is faster or more faithful than Selenium. Choose according to your existing dependencies, target browser behavior, and required capture area. See the Playwright library guide and screenshot guide.
Or skip the browser setup
If you want an image from a URL without managing a local Selenium browser session, ScreenshotNeo provides a screenshot API and MCP server. One GET request returns an image or PDF. See the ScreenshotNeo website and API documentation.
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
- Cookie banners are accepted and removed before capture, along with known newsletter popups and chat widgets; each of those steps can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers report the page verdict and billing status.
- An MCP server exposes screenshot, page-info, and PDF capture tools to AI agents and 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’s free plan to try 1,000 screenshots a month without a card.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Frequently Asked Questions
Can Selenium save the screenshot as JPEG or WebP?
The Selenium screenshot methods documented here save PNG output. Use an image-processing step after capture if you need another format.
Does capturing a local HTML file require a web server?
No. The example opens the resolved file directly with a file URL. A server is only needed if your page or its assets specifically depend on being served over HTTP.
Quick Recap
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.

