Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
For a single-file copy of a page rendered in Chromium, use Selenium to load the page, wait for the content you need, then call Chrome DevTools Protocol’s Page.captureSnapshot with format set to mhtml. Save the returned data as a .mhtml file. Unlike Selenium’s page_source, this can package the page with its external resources, including CSS and images.
Save the rendered page as one MHTML file
This method uses Selenium’s Python API to send a Chrome DevTools Protocol (CDP) command to the browser. It is for Chromium browsers, such as Chrome. The resulting MHTML file is a single archive that can be opened in a browser that supports MHTML.
Install Selenium and ensure a compatible Chrome browser and driver are available. Recent Selenium releases can manage the driver through Selenium Manager when a suitable browser installation is present; if driver startup fails, check the Selenium installation and your browser/driver setup.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →from pathlib import Path
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
url = "https://example.com"
out = Path("page.mhtml")
driver = webdriver.Chrome()
try:
driver.get(url)
# Replace this with a condition that proves the content you need is ready.
WebDriverWait(driver, 30).until(
lambda d: d.find_element(By.TAG_NAME, "body")
)
snapshot = driver.execute_cdp_cmd(
"Page.captureSnapshot", {"format": "mhtml"}
)
out.write_text(snapshot["data"], encoding="utf-8")
finally:
driver.quit()
Change url to the page you want and out to the destination filename. The output directory must exist and be writable. The wait shown confirms that a body element exists; it is only a starting point, not proof that a JavaScript application has finished rendering its main content.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Why MHTML works better than page_source
Selenium’s driver.page_source returns the current page source. Saving that string as an HTML file does not also download or bundle its linked stylesheets and images. CDP’s Page.captureSnapshot returns a serialized page; its MHTML format includes iframes, shadow DOM, external resources, and element-inline styles, as described in the Chrome DevTools Protocol Page documentation.
The snapshot is what the browser can serialize at capture time. It is not a guarantee that every resource will be available offline: a resource may be blocked, require credentials, be unavailable across origins, stream continuously, or be requested only after capture.
Wait for the content, not just navigation
By default, Selenium navigation waits for the document ready state to reach complete. Selenium also offers three page-load strategies: normal waits for the load event, eager waits for DOMContentLoaded, and none does not wait for navigation to complete. These milestones do not necessarily mean a dynamic page has finished fetching and rendering the content you want. A single-page application can continue making requests after readyState is complete.
Free tools Windows power users keep installed
One-click scans. No signup required.
Wait for a meaningful page element
If the page has a stable article, product, or results selector, wait for it instead of the generic body:
WebDriverWait(driver, 30).until(
lambda d: d.find_element(By.CSS_SELECTOR, "main article")
)
Replace main article with a selector that matches the target page. For content that appears asynchronously, wait for the actual text or state that indicates it is ready. For example, an application-specific status element may change from “Loading” to a completed state. Choose a condition that reflects the page’s behavior rather than assuming a fixed delay will work every time.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Choose a page-load strategy only when needed
The default normal strategy is a reasonable baseline. Use eager if waiting for the full load event is too slow and you will explicitly wait for the content afterward; use none only when your script handles navigation readiness itself. These strategies change when navigation returns; they do not replace an explicit wait for dynamic application content.
For a custom strategy, configure Chrome options before creating the driver:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.page_load_strategy = "eager" # "normal", "eager", or "none"
driver = webdriver.Chrome(options=options)
Keep the CDP call inside the driver’s lifetime. Capture the snapshot, write its returned string to disk, and only then quit the browser.
What “complete” means—and what it does not
MHTML is useful when you want one file containing the browser’s serialized page and resources, rather than an HTML file that points to separate assets. The CDP documentation specifically lists iframes, shadow DOM, external resources, and element-inline styles as part of MHTML serialization.
- It captures the rendered browser page, not a universal offline copy. Resources unavailable to the browser or excluded from serialization cannot be recovered by saving the snapshot.
- Authentication can matter. The browser must be able to load protected resources in the session; a later offline reader may not reproduce a page whose functionality depends on a live service.
- Timing matters. A lazy-loaded image or content block that has not loaded by capture time may not be present in the archive.
- Some page behavior is inherently online. Streaming content, live data, and interactions that request new resources cannot be assumed to work offline just because an MHTML file exists.
For a folder with an HTML file plus separate CSS and image files, MHTML is the wrong output format. That workflow requires downloading resources and updating links; page_source alone does not create such a folder.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Use page_source as an HTML-only fallback
If you do not need bundled resources, Selenium can save the current HTML source directly. This is also a fallback for a browser driver that does not support the Chromium CDP command:
Windows 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 reinstallCrashes, 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 minutefrom pathlib import Path
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
url = "https://example.com"
out = Path("page.html")
driver = webdriver.Chrome()
try:
driver.get(url)
WebDriverWait(driver, 30).until(
lambda d: d.execute_script("return document.readyState") == "complete"
)
out.write_text(driver.page_source, encoding="utf-8")
finally:
driver.quit()
This saves HTML, not a self-contained page with its linked assets. Relative links may also resolve differently when the file is opened locally. For a complete single-file archive, use MHTML with a Chromium driver; a non-Chromium browser may need its own browser-native archival mechanism.
Troubleshoot common failures
“unknown command” or CDP command failure
Page.captureSnapshot is a Chromium CDP command. A non-Chromium driver may not expose it, and browser/driver combinations can differ in supported protocol commands. Use a compatible Chromium browser and driver, or save page_source if HTML alone is acceptable.
The saved file is missing content or images
The capture may have run before the application finished rendering or before lazy-loaded resources were requested. Replace the body-only wait with a wait for the page’s real content, and ensure the browser has had an opportunity to load the resources you expect. If the resource is blocked, protected, or only fetched after an interaction, a snapshot cannot make it available automatically.
The page opens but styles or images are absent
Confirm that you saved snapshot["data"] from an MHTML capture rather than driver.page_source, and that the file has an .mhtml extension. HTML source alone references assets; it does not embed them. Also distinguish assets absent from the archive from assets that are present but not displayed by the application used to open the file.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
The output file is empty or not written
Check that the capture completed before the write, that the output path is correct, and that the process has permission to write there. Keep the driver open until execute_cdp_cmd returns and the data has been written; the finally block should close the browser afterward.
Navigation hangs or returns too early
A long-running page may delay the default load event, while a fast navigation return may still precede application content. Adjust the page-load strategy only if appropriate, then add a condition tied to the content you need. Prefer an explicit wait over a guessed sleep duration.
Driver startup fails
Verify that Selenium is installed and that Chrome is installed and launchable in the execution environment. If automatic driver management cannot obtain or use a compatible driver, provide a compatible driver setup for that environment. The MHTML command cannot run until the browser session is established.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If you need a screenshot rather than an offline MHTML archive, ScreenshotNeo offers a website screenshot API and MCP server. This is not a substitute for saving a self-contained web page: it returns an image or PDF, not an MHTML archive.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →One GET request can capture a page; the Python example below saves the returned image. See the ScreenshotNeo documentation for the API options and response details.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://example.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
- 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 step can be turned off.
- Bot checks and CAPTCHAs, blank pages, failed loads, timeouts, and cache hits are not billed; response headers report the page verdict and billing status.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for AI agents and other MCP clients. - The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.
Frequently Asked Questions
Can Selenium save a webpage as a single file with CSS and images?
Yes. With a Chromium browser, use CDP’s MHTML snapshot method shown above; it packages the serialized page and available resources into one file.
Will an MHTML snapshot work in Firefox?
The capture command in this guide is Chromium-specific. Use a browser-native archival option for a non-Chromium browser, or save HTML only with Selenium’s page_source.
Recommended Free Tools
Does saving page_source download images and CSS?
No. It returns HTML source. It does not bundle linked stylesheets or image files.
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.

