Start the runtime
# Windows
./mimic.exe -listen 127.0.0.1:9222
# Linux
./mimic -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://example.com/")
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://example.com/");
const links = await page.locator("a").evaluateAll(
nodes => nodes.map(a => ({ text: a.textContent, url: a.href }))
);
console.log(links);
} finally {
await browser.close();
}Raw CDP · Read browser state
Connect your WebSocket client to a Page’s webSocketDebuggerUrl fromhttp://127.0.0.1:9222/json/list, then send this JSON message.
{
"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.