Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsUse Selenium with Chromium’s DevTools Protocol (CDP) to save the rendered page as a single MHTML archive. After navigation and an application-specific wait, call Page.captureSnapshot with format: "mhtml", then write the returned string to a file. MHTML packages the captured document, iframes, shadow DOM, external resources such as stylesheets and images, and element-inline styles. Selenium’s page_source is useful as an HTML fallback, but it does not download linked CSS or image files by itself.
What you will create
The result is one .mhtml (also called MHTML or MIME HTML) file that can be opened in a Chromium browser for offline viewing. It is different from saving only the DOM: the archive contains the resources that Chromium captured while rendering the page.
- Best fit: Chromium-based browsers driven by Selenium, including Chrome and Chromium.
- Output: one archive file rather than an HTML file plus an assets folder.
- Dynamic pages: content must be present before the snapshot command runs.
- Not a guarantee of everything ever requested: authenticated, blocked, streaming, cross-origin, or post-capture resources may not be available offline.
Prerequisites and browser setup
Install Python packages
Recent Selenium releases can manage a compatible ChromeDriver in common setups. Install Selenium in your virtual environment:
python -m pip install -U selenium
Have a current Chrome or Chromium installation available. If your environment requires a separately managed driver, ensure its major version matches the browser.
#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.
Choose a page-load strategy
Selenium supports normal, eager, and none strategies. normal waits for the load event, eager returns after DOMContentLoaded, and none does not wait for navigation completion. A single-page application can continue fetching data after any of these points, so use an explicit wait for the content you actually need.
Complete Python example: save the rendered page as MHTML
This example waits for the body, captures the page through CDP, writes the archive, and always closes the browser.
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")
options = webdriver.ChromeOptions()
# options.add_argument("--headless=new") # enable for a server or CI job
# "normal" is the default. Set it explicitly when readability matters.
options.page_load_strategy = "normal"
driver = webdriver.Chrome(options=options)
try:
driver.get(url)
# Replace this with a selector that proves your application 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")
print(f"Saved {out.resolve()}")
finally:
driver.quit()
Open page.mhtml in Chrome or another browser that supports MHTML. Keep the driver alive until execute_cdp_cmd returns and the string has been written; quitting first can interrupt the capture or leave an incomplete file.
Wait for the content your page needs
Waiting for a body element only proves that the document has a body. Replace it with a condition tied to the page’s real state.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →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.
Wait for a stable article or product element
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 30).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, "article"))
)
Wait for a loading indicator to disappear
WebDriverWait(driver, 30).until(
EC.invisibility_of_element_located((By.CSS_SELECTOR, ".loading"))
)
Wait for application state with JavaScript
WebDriverWait(driver, 30).until(
lambda d: d.execute_script(
"return document.querySelector('[data-ready="true"]') !== null"
)
)
Allow lazy content to render
For pages that load images as they approach the viewport, scroll in increments and then wait for the final selector before capturing:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
WebDriverWait(driver, 30).until(
EC.presence_of_element_located((By.CSS_SELECTOR, "footer"))
)
Scrolling is page-specific. It can trigger lazy images, but it does not force every custom application request to finish. Wait for a meaningful completion signal when one exists.
Why MHTML is preferable to page_source for a complete copy
| Approach | What it captures | Output | Main limitation |
|---|---|---|---|
Page.captureSnapshot with MHTML |
Rendered document plus captured iframes, shadow DOM, external resources and element-inline styles | One archive file | Chromium CDP only; resources unavailable to the browser cannot be embedded |
driver.page_source |
Current page source exposed by WebDriver | HTML text | Does not package linked CSS, images or other resource files |
| Custom downloader | Resources selected and fetched by your code | Usually an HTML file and asset directory | You must resolve URLs, cookies, redirects, MIME types and rewriting yourself |
Use the HTML fallback when you need a portable, browser-neutral source snapshot or when CDP is unavailable:
html = driver.page_source
Path("page.html").write_text(html, encoding="utf-8")
This fallback preserves markup, not a self-contained offline page. Relative links may still point to the original site, and external stylesheets and images remain external.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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.
Handling dynamic, authenticated and restricted pages
Single-page applications
Navigation can report completion while JavaScript is still fetching API data. Wait for the table, article, chart, or status element that represents the finished state. If the application has no reliable selector, wait for a known text change or a bounded delay after a network-driven event, then verify the visible result before capturing.
Login-protected content
Log in through Selenium before calling Page.captureSnapshot. The archive contains what the browser could access in that session; it does not turn protected URLs into public files. Session-dependent requests, expiring URLs, or resources rejected by access controls may fail when the archive is reopened.
Cross-origin frames
The CDP snapshot format is designed to include iframes, but a frame that is blocked, still loading, or dependent on an unavailable session may not render offline. Check the saved file in a clean browser profile rather than assuming that a successful command means every frame is usable.
Streaming and post-capture requests
Live video, WebSockets, continuously updating feeds and requests started after the snapshot are not archival guarantees. Capture at a defined point in time and record that limitation if the file is being used as evidence.
Free tools Windows power users keep installed
One-click scans. No signup required.
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
Controlling Chrome for repeatable captures
Headless operation
For CI or servers, add --headless=new. Use the same viewport and device settings for comparable captures; responsive layouts can change the HTML and the resources requested.
Viewport and page state
Set the window size before navigation when the page’s responsive breakpoint matters:
options.add_argument("--window-size=1440,1200")
Perform required interactions—opening an accordion, selecting a tab, dismissing a dialog, or accepting a consent prompt—before capturing. The archive reflects the state visible to the browser at that moment.
Waiting without hanging forever
Always use a finite timeout. On timeout, save diagnostics such as the current URL, title and a screenshot, then quit the driver. A retry should create a new browser session so stale state does not contaminate the next attempt.
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.
try:
WebDriverWait(driver, 30).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, "main"))
)
except Exception:
driver.save_screenshot("capture-timeout.png")
print(driver.current_url, driver.title)
raise
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
unknown command: Page.captureSnapshot |
The driver is not controlling a Chromium browser, or the command is unavailable in that browser version. | Use Chrome or Chromium with a compatible Selenium/driver combination. For another browser, use page_source or that browser’s native archival feature. |
| The file contains a shell page but not the article | The snapshot ran before client-side rendering completed. | Wait for the article’s stable selector, loaded text, or application-ready marker rather than only calling get(). |
| Images are missing offline | An image was lazy-loaded later, blocked, protected, or unavailable when captured. | Trigger lazy loading by scrolling, wait for image completion where appropriate, and verify the archive in a fresh profile. The method cannot embed a resource the browser never obtained. |
KeyError: 'data' |
The command failed or returned an unexpected response. | Log the complete CDP response, check browser/driver compatibility, and confirm that the command is sent before quitting. |
| Chrome fails to start in CI | Missing browser binaries, sandbox restrictions or incompatible driver. | Install a matching Chrome/Chromium and driver, use the CI-approved headless and sandbox flags, and inspect the driver log. |
| The MHTML opens but links still reach the Internet | Those links are navigation links, not embedded resources. | That is normal. MHTML embeds captured resources; it does not rewrite every hyperlink into an offline site. |
Performance, reliability and storage considerations
- Capture time: most delay comes from navigation and your readiness condition, not the final CDP call. A long timeout prevents premature archives but increases worst-case runtime.
- Memory: large pages, numerous images and long DOM trees produce large strings and files. Write the returned data promptly and avoid keeping multiple snapshots in memory.
- Determinism: use a fixed viewport, locale, authentication state and capture time when comparing versions. Ads, personalized content and live data can change between runs.
- Retries: retry navigation failures with a new driver, but do not blindly retry a page that consistently fails its readiness condition. Preserve the failure URL and browser logs.
- Security: MHTML can contain private page data, cookies embedded in resource URLs, and sensitive text. Store it with appropriate permissions and avoid sharing archives from authenticated sessions.
When you need a folder of HTML, CSS and images
MHTML is the practical single-file equivalent of the browser’s “save complete page” behavior. If your workflow specifically requires index.html plus separate assets, Selenium alone is not a complete downloader. You must collect resource URLs, fetch them with the required cookies and headers, save each response, and rewrite the HTML and CSS references. That workflow must also handle redirects, duplicate URLs, data URIs, fonts, responsive sources, cache headers and failures. Use it only when a folder structure is a hard requirement; otherwise MHTML avoids a large class of URL-rewriting errors.
Or skip the browser setup
ScreenshotNeo provides a website screenshot API when you need a rendered image or PDF rather than an editable offline archive. A single GET request can return PNG, JPEG, WebP or PDF:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
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)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo documentation for request options. Before capture, it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. 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, and every feature is available on every plan.
Create a free ScreenshotNeo account to get the 1,000 monthly screenshots without adding a card.
Practical decision guide
| Your requirement | Use |
|---|---|
| One offline file containing the rendered page and captured resources | Chromium Selenium plus Page.captureSnapshot in MHTML format |
| Only the current HTML markup | driver.page_source |
| A browser-neutral asset folder | A purpose-built downloader that saves and rewrites resources |
| A screenshot or PDF without maintaining ChromeDriver | ScreenshotNeo’s API |
Frequently Asked Questions
Can Firefox Selenium create the same MHTML archive?
The documented Page.captureSnapshot command is a Chromium CDP command. With Firefox or another non-Chromium driver, use an HTML fallback or that browser’s own archival mechanism instead.
Does MHTML preserve JavaScript so the page remains interactive?
It preserves the captured document and resources, but offline behavior is not guaranteed for scripts that depend on network APIs, authentication, streaming data or services that are no longer reachable.
How can I confirm that CSS and images were actually embedded?
Open the saved file in a fresh browser profile with networking disabled or unavailable, then inspect the rendered page. Missing resources usually indicate that they were not loaded, were blocked, or required a live session.
Is MHTML suitable as a legal or compliance record?
Treat it as a record of what the browser captured at a particular time, not proof that every remote request or server-side state was preserved. Document the URL, timestamp, account context and known capture limitations.
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.

