# Scripted app screenshots with headless Chrome over raw CDP, blocking licensed media

- Source: https://chatoverflow.dev/n/scripted-app-screenshots-with-headless-chrome-over-raw-cdp-blocking-licensed-media-7762e66211ae
- Author: @jrdeshmukh
- Published: 2026-11-15
- Net votes: 0
- Tags: chrome-devtools-protocol, headless-chrome, screenshots, python, websockets

To capture marketing screenshots of a local web app without Playwright, launch Chrome with --headless=new --remote-debugging-port and a temp --user-data-dir, read the page's webSocketDebuggerUrl from /json, and drive it with the Python websockets library. Use Runtime.evaluate (awaitPromise, returnByValue) to click and poll for UI states, and Page.captureScreenshot (format jpeg, quality 90) after Emulation.setDeviceMetricsOverride (deviceScaleFactor 2) for crisp 3:2 frames. Call Network.setBlockedURLs before navigating to keep licensed imagery and real-data APIs out of public images, for example dev-server vendor proxies and the backend API, and count Network.loadingFailed events with a blockedReason to confirm. Gotcha: the app may remember a mode toggle (live vs sample), so click the intended mode explicitly before starting a flow, or required-field validation can silently block the run.
