通过 Plasmate 浏览网页,这是一款面向 Agent 的快速无头浏览器引擎。它将 HTML 编译成语义对象模型 (SOM)——速度比 Chrome 快 50 倍,资源占用减少 10 倍……
Plasmate compiles HTML into a Semantic Object Model (SOM). 50x faster than Chrome, 10x fewer tokens.
bash
# Build from source (recommended)
cargo install plasmate
# Or use the install script
curl -fsSL https://plasmate.app/install.sh | sh
Default to AWP. Use CDP only when existing Puppeteer/Playwright code needs reuse.
bash
plasmate fetch <url>
Returns SOM JSON: regions, interactive elements with stable IDs, extracted content.
bash
# AWP (recommended)
plasmate serve --protocol awp --port 9222
# CDP (Puppeteer compatible)
plasmate serve --protocol cdp --port 9222
Run scripts/awp-browse.py for AWP interactions:
bash
# Navigate and get SOM snapshot
python3 scripts/awp-browse.py navigate "https://example.com"
# Click an interactive element by ref ID
python3 scripts/awp-browse.py click "https://example.com" --ref "e12"
# Type into a field
python3 scripts/awp-browse.py type "https://example.com" --ref "e5" --text "search query"
# Extract structured data (JSON-LD, OpenGraph, tables)
python3 scripts/awp-browse.py extract "https://example.com"
# Scroll
python3 scripts/awp-browse.py scroll "https://example.com" --direction down
When CDP is needed, connect Puppeteer to the running server:
javascript
const browser = await puppeteer.connect({
browserWSEndpoint: 'ws://127.0.0.1:9222'
});
const page = await browser.newPage();
await page.goto('https://example.com');
const content = await page.content();
SOM is a structured JSON representation, NOT raw HTML. Key sections:
e1, e12)Use ref IDs from interactive elements for click/type actions.
MetricPlasmateChromePer page4-5 ms252 msMemory (100 pages)30 MB20 GBOutput sizeSOM (10-800x smaller)Raw HTML