ScreenshotNeo

BlogHow-to

How to capture thumbnails for HTTPS websites with certificate errors

Use Playwright to capture a site despite HTTPS certificate errors, and learn why that does not capture the browser warning or fix the certificate.

By the ScreenshotNeo team4 October 20267 min read

If you want a thumbnail of the website’s rendered content, configure a Playwright browser context with ignoreHTTPSErrors: true, navigate to the HTTPS URL, then take a screenshot. The option defaults to false. This lets the automation attempt to load a site despite a certificate error; it does not repair, renew, or validate the site’s certificate. Playwright browser context documentation.

First decide which image you need: the website as rendered, or the browser’s own certificate warning page. The workflow below captures the site’s rendered page when the browser can load it. A certificate warning is browser UI, not ordinary page content, and the sources reviewed do not establish a reliable cross-browser way to capture that interstitial with a page screenshot.

Capture the rendered website with Playwright

This runnable Node.js example creates a context that ignores HTTPS errors, navigates to a URL, waits for the page’s load event, and writes a full-page PNG. Install Playwright and its matching Chromium binary first:

npm install playwright
npx playwright install chromium

Save as capture.mjs and run with node capture.mjs https://example.com:

import { chromium } from 'playwright';

const target = process.argv[2];
if (!target) {
  throw new Error('Usage: node capture.mjs https://example.com');
}

const browser = await chromium.launch({ headless: true });
try {
  const context = await browser.newContext({
    ignoreHTTPSErrors: true,
    viewport: { width: 1280, height: 800 },
  });
  const page = await context.newPage();
  const response = await page.goto(target, {
    waitUntil: 'load',
    timeout: 30000,
  });

  console.log('HTTP status:', response?.status() ?? 'no main-resource response');
  console.log('Final URL:', page.url());
  await page.screenshot({ path: 'thumbnail.png', fullPage: true });
  await context.close();
} finally {
  await browser.close();
}

ignoreHTTPSErrors belongs on the browser context, so pages opened in that context inherit the setting. Playwright’s page.screenshot() captures the rendered page; fullPage: true expands the capture to the full scrollable page. See the Playwright screenshot API.

Choose a wait condition that fits the site

  • load waits for the load event and is a practical default for a thumbnail.
  • domcontentloaded can return sooner when the site keeps long-running resources open, but images or client-rendered content may not be ready.
  • networkidle waits for network activity to settle. Analytics, polling, and other ongoing requests can prevent it from settling, so use a timeout or a more specific readiness condition for those pages.
  • For a known page element, wait for it explicitly with await page.locator('main').waitFor(), or wait for a short, deliberate delay if the page renders content after navigation.

Navigation can fail for reasons other than certificate validation, including DNS failure, connection refusal, or timeout. Ignoring HTTPS errors only changes handling of certificate errors; it cannot make an unavailable server render.

Python version

Install the Python package and its browser binary:

pip install playwright
playwright install chromium

Save as capture.py and run python capture.py https://example.com:

import asyncio
import sys
from playwright.async_api import async_playwright

async def main():
    if len(sys.argv) < 2:
        raise SystemExit('Usage: python capture.py https://example.com')
    target = sys.argv[1]

    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=True)
        try:
            context = await browser.new_context(
                ignore_https_errors=True,
                viewport={"width": 1280, "height": 800},
            )
            page = await context.new_page()
            response = await page.goto(target, wait_until="load", timeout=30000)
            print("HTTP status:", response.status if response else "no main-resource response")
            print("Final URL:", page.url)
            await page.screenshot(path="thumbnail.png", full_page=True)
            await context.close()
        finally:
            await browser.close()

asyncio.run(main())

The Python option is named ignore_https_errors. It has the same context-level effect as Node’s ignoreHTTPSErrors.

cURL: what it can and cannot capture

cURL does not render a web page or produce a visual thumbnail. Its -k / --insecure option skips certificate verification for an HTTP request, which can help inspect the server response but does not create a screenshot. Do not use this as a browser-rendering substitute:

curl --insecure --location --output response.html https://example.com

For an image, use browser automation such as the Playwright examples above, or use a screenshot API. Skipping certificate verification weakens the connection’s identity checks; limit it to cases where you understand the risk.

Configuration choices and edge cases

Need Configuration or behavior
Capture the whole page Set fullPage: true in page.screenshot(). Very tall pages can consume more memory and produce large image files.
Capture a fixed thumbnail viewport Set a deliberate context viewport, such as 1280 × 800, and omit fullPage or set it to false.
Capture one element Locate it and call locator.screenshot({ path: 'thumbnail.png' }). It must exist and be visible; wait for it before capture.
Capture a PDF Use Chromium’s page.pdf() in a headless context if a PDF is the desired output. PDF output is different from a thumbnail image.
Site redirects Log page.url() and the main navigation response status so the saved image can be tied to the final destination.
Certificate warning interstitial Do not assume a page screenshot includes browser chrome or interstitial UI. Verify the exact browser and capture method if the warning itself is the required image.
Client certificate request That is TLS client authentication, not a server certificate error. Playwright’s clientCertificates option is for a server requesting a client certificate and is scoped to an origin.

Playwright documents context options and client certificates separately. A client certificate will not fix an expired, self-signed, or hostname-mismatched server certificate.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request can return a screenshot or PDF. See the API documentation for parameters and response details.

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

It also works with Python:

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)

And Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers report the page verdict and billing status. Its MCP server lets AI agents call screenshot, page-info, and PDF tools. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. These product facts describe ScreenshotNeo’s capture and billing behavior; they do not establish that a target certificate error is ignored, so check the API documentation for current HTTPS handling before relying on it for an invalid-certificate target.

Create a free ScreenshotNeo account for 1,000 screenshots a month with no card.

Troubleshooting

Symptom Likely cause Fix
Navigation still fails with a certificate error The setting was omitted, applied to a different context, or the failure is not a certificate error. Create the page from a context with ignoreHTTPSErrors enabled. Inspect the navigation error and confirm the failure is on the target HTTPS request.
Browser shows a blank page or network error page The server may be unreachable, the page may have failed for a non-certificate reason, or the browser returned an error document. Check DNS, connectivity, response status, redirects, and console/network errors. Ignoring certificate errors does not bypass other network failures.
Screenshot shows a loading shell or missing images Capture occurred before client rendering or image loading completed. Wait for a page-specific selector, use an appropriate navigation condition, or add a bounded delay. Avoid waiting indefinitely for network idle on pages with continuous requests.
Chromium executable is missing The Playwright package and browser binaries may not be installed together. Run npx playwright install chromium for Node.js or playwright install chromium for Python after installing/updating Playwright. Playwright requires matching browser binaries.
Browser download fails behind a company proxy The local proxy may intercept TLS and use a private CA that the download process does not trust. For this browser-download scenario, Playwright documents adding the CA through NODE_EXTRA_CA_CERTS. This is separate from accepting the target website’s certificate error.
Saved image is the site error page rather than the warning The screenshot API captures page content, not necessarily browser UI. Confirm whether the desired artifact is rendered site content or the browser-generated interstitial. Treat interstitial capture as browser-specific and verify the chosen approach.

Sources: Playwright Browser API, Playwright Page screenshot API, Playwright browser management, and Chromium security documentation.

Performance, reliability, and cost

  • Performance: Reuse a browser process for multiple captures when running a service, but create an appropriately isolated context per job. Set navigation and overall job timeouts, and keep full-page captures to the pages and dimensions you need.
  • Reliability: Pin or record the Playwright version and install its corresponding browser binary. Record target URL, final URL, browser version, navigation outcome, and whether the output is the rendered site or an error page. Retry only transient failures with a limit; a retry will not fix a persistent certificate or server configuration error.
  • Security: Ignore certificate errors only for the capture task that needs it. The browser no longer verifies the server certificate for that context, so the screenshot should not be treated as evidence that the connection or site is trusted.
  • Cost: Playwright itself is open-source software, but operating captures has infrastructure costs: CPU and memory for browser processes, storage for images, and engineering time for browser updates and failure handling. No benchmark or fixed per-capture cost is implied. ScreenshotNeo offers 1,000 free shots monthly and paid plans from $5 for 3,000; only clean shots are billed.

FAQ

Does ignoring HTTPS errors fix the website certificate?

No. It changes how that automation context handles certificate failures. The website owner must fix the server certificate to restore normal trusted HTTPS.

Can I safely use this on every URL?

Use it only when you intentionally need a capture despite a certificate problem. Skipping certificate validation removes an important server identity check.

Will the screenshot show the browser’s certificate warning?

Not necessarily. The examples capture rendered page content. Browser-generated warning screens are a separate requirement and need verification for the specific browser and capture method.

Is a client certificate the same thing?

No. A client certificate authenticates the client to a server that requests it. It does not repair the server’s certificate.