Plasmate - Browser Engine for Agents
Plasmate compiles HTML into a Semantic Object Model (SOM). 50x faster than Chrome, 10x fewer tokens.
- - Docs: https://docs.plasmate.app
- Source: https://github.com/plasmate-labs/plasmate (Apache 2.0)
- Privacy: All processing runs locally. No telemetry or cloud services.
Install
CODEBLOCK0
Protocols
- - AWP (native): 7 methods - navigate, snapshot, click, type, scroll, select, extract
- CDP (compatibility): Puppeteer/Playwright compatible on port 9222
Default to AWP. Use CDP only when existing Puppeteer/Playwright code needs reuse.
Quick Start
Fetch (one-shot, no server)
CODEBLOCK1
Returns SOM JSON: regions, interactive elements with stable IDs, extracted content.
Server Mode
CODEBLOCK2
AWP Usage (Python)
Run scripts/awp-browse.py for AWP interactions:
CODEBLOCK3
CDP Usage (Puppeteer)
When CDP is needed, connect Puppeteer to the running server:
CODEBLOCK4
SOM Output Structure
SOM is a structured JSON representation, NOT raw HTML. Key sections:
- - regions: Semantic page areas (nav, main, article, sidebar)
- interactive: Clickable/typeable elements with stable ref IDs (e.g.,
e1, e12) - content: Text content organized by region
- structured_data: JSON-LD, OpenGraph, microdata extracted automatically
Use ref IDs from interactive elements for click/type actions.
Performance
| Metric | Plasmate | Chrome |
|---|
| Per page | 4-5 ms | 252 ms |
| Memory (100 pages) |
~30 MB | ~20 GB |
| Output size | SOM (10-800x smaller) | Raw HTML |
When to Use Plasmate vs Browser Tool
- - Plasmate: Speed-critical scraping, batch page processing, token-sensitive extraction, structured data
- Browser tool: Visual rendering needed, screenshots, complex JS SPAs requiring full Chrome engine, pixel-level interaction
Plasmate - 面向智能体的浏览器引擎
Plasmate 将 HTML 编译为语义对象模型(SOM)。速度比 Chrome 快 50 倍,Token 消耗减少 10 倍。
- - 文档:https://docs.plasmate.app
- 源码:https://github.com/plasmate-labs/plasmate(Apache 2.0 许可)
- 隐私:所有处理均在本地运行。无遥测或云服务。
安装
bash
从源码构建(推荐)
cargo install plasmate
或使用安装脚本
curl -fsSL https://plasmate.app/install.sh | sh
协议
- - AWP(原生):7 个方法 - navigate、snapshot、click、type、scroll、select、extract
- CDP(兼容):在 9222 端口上兼容 Puppeteer/Playwright
默认使用 AWP。仅在需要复用现有 Puppeteer/Playwright 代码时使用 CDP。
快速开始
单次抓取(无需服务器)
bash
plasmate fetch
返回 SOM JSON:区域、带有稳定 ID 的可交互元素、提取的内容。
服务器模式
bash
AWP(推荐)
plasmate serve --protocol awp --port 9222
CDP(兼容 Puppeteer)
plasmate serve --protocol cdp --port 9222
AWP 使用(Python)
运行 scripts/awp-browse.py 进行 AWP 交互:
bash
导航并获取 SOM 快照
python3 scripts/awp-browse.py navigate https://example.com
通过 ref ID 点击可交互元素
python3 scripts/awp-browse.py click https://example.com --ref e12
在字段中输入
python3 scripts/awp-browse.py type https://example.com --ref e5 --text 搜索查询
提取结构化数据(JSON-LD、OpenGraph、表格)
python3 scripts/awp-browse.py extract https://example.com
滚动
python3 scripts/awp-browse.py scroll https://example.com --direction down
CDP 使用(Puppeteer)
当需要使用 CDP 时,将 Puppeteer 连接到运行中的服务器:
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 输出结构
SOM 是结构化的 JSON 表示,而非原始 HTML。关键部分:
- - regions:语义页面区域(导航、主体、文章、侧边栏)
- interactive:带有稳定 ref ID(例如 e1、e12)的可点击/可输入元素
- content:按区域组织的文本内容
- structured_data:自动提取的 JSON-LD、OpenGraph、微数据
使用 interactive 元素中的 ref ID 进行点击/输入操作。
性能
| 指标 | Plasmate | Chrome |
|---|
| 每页处理时间 | 4-5 毫秒 | 252 毫秒 |
| 内存(100 页) |
约 30 MB | 约 20 GB |
| 输出大小 | SOM(小 10-800 倍) | 原始 HTML |
何时使用 Plasmate 而非浏览器工具
- - Plasmate:对速度要求高的抓取、批量页面处理、对 Token 敏感的提取、结构化数据
- 浏览器工具:需要视觉渲染、截图、需要完整 Chrome 引擎的复杂 JS SPA、像素级交互