Demo site: Books to Scrape.
Follow the SDK guide to start Mimic from your app. The examples below connect directly to a runtime you manage yourself.
Direct CDP · Start the runtime
# Windows
./mimic.exe --browser-mode headless --listen 127.0.0.1:9222
# Linux
./mimic --browser-mode headless --listen 127.0.0.1:9222Python · Extract content
Install the client with pip install playwright. Connecting over CDP does not require downloading Playwright’s browser.
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.connect_over_cdp("http://127.0.0.1:9222")
page = browser.contexts[0].new_page()
page.goto("https://books.toscrape.com/", wait_until="load")
print(page.locator("h1").inner_text())
browser.close()Node.js · Collect links
Install with npm install playwright-core. Run the example as an .mjs file.
import { chromium } from "playwright-core";
const browser = await chromium.connectOverCDP("http://127.0.0.1:9222");
try {
const page = await browser.contexts()[0].newPage();
await page.goto("https://books.toscrape.com/", { waitUntil: "load" });
const links = await page.locator(".product_pod h3 a").evaluateAll(
nodes => nodes.map(a => ({ text: a.title, url: a.href }))
);
console.log(links);
} finally {
await browser.close();
}Raw CDP · Read browser state
Connect your WebSocket client to a Page’s webSocketDebuggerUrl from http://127.0.0.1:9222/json/list, after loading https://books.toscrape.com/ with either example above. Then send this JSON message. The returned title is All products | Books to Scrape - Sandbox.
{
"id": 1,
"method": "Runtime.evaluate",
"params": {
"expression": "({ title: document.title, url: location.href })",
"returnByValue": true
}
}CDP commands depend on the supported surface. Check compatibility before adapting your workload.
Read Run Playwright without Chromium for a complete extraction example, or Mimic versus Chromium for workload selection and measured memory boundaries.