servo-fetch
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
A self-contained browser engine that fetches, renders, and extracts web content as Markdown, JSON, or screenshots — no Chromium, no API key, no setup.
servo-fetch embeds the Servo browser engine. It executes JavaScript, computes CSS layout,
captures screenshots with a software renderer, and extracts clean content — available as a CLI, a Rust library,
a Python SDK, and a Node.js SDK.
Why servo-fetch
- **Zero dependencies** — single binary, no Chromium, no API key
- **Real JS execution** — SpiderMonkey runs JavaScript, parallel CSS engine computes layout
- **Layout- and visibility-aware extraction** — strips navbars, sidebars, footers by rendered position, plus cookie banners, modals, and CSS-hidden content (opacity:0, aria-hidden, sr-only)
- **Schema-driven JSON** — declarative CSS-selector schema pulls structured data
- **Parallel batch fetch** — multiple URLs fetched concurrently
- **Isolated browser sessions** — one-use worker process per session keeps cookies and storage fully separated
- **Site crawling** — BFS link traversal with robots.txt, same-site scope, and rate limiting
- **URL discovery** — sitemap-based URL mapping without rendering (fast, lightweight)
- **Screenshots without GPU** — software renderer captures PNG/full-page screenshots anywhere
- **Accessibility tree** — AccessKit integration with roles, names, and bounding boxes
- **Agent-ready** — drop-in web tool for AI agents: a built-in MCP server, or wrap the Python API as a tool in any agent framework
Performance and quality
Apple M3 Pro, versus Playwright (the typical AI-agent stack):
| Benchmark | servo-fetch | playwright:optimized |
| ------------------- | ----------: | -------------------: |
| Time — static-small | ~231 ms | ~645 ms |
| Time — spa-heavy | ~331 ms | ~798 ms |
| Memory (peak RSS) | 51–64 MB | 300–328 MB |
Extraction quality: mean word-F1 0.819 vs Readability's 0.728 across
eight page-type fixtures, with without[] boilerplate removal at 95.0%
vs 78.6%. Direct-binary engine peers (chrome-headless-shell, Lightpanda,
curl) are opt-in.
Methodology, three-axis breakdown, per-fixture F1, and raw JSON:
benchmarks/README.md +
benchmarks/results/.
Install
| Interface | Install | Docs |
| --------- | ------- | ---- |
| **CLI** | curl -fsSL https://raw.githubusercontent.com/konippi/servo-fetch/main/install.sh \| sh | CLI docs |
| **Rust** | cargo add servo-fetch | Library docs |
| **Python** | pip install servo-fetch | Python docs |
| **Node.js** | npm install servo-fetch | Node docs |
CLI install alternatives
Or download from GitHub Releases.
**Linux** — install runtime deps and use xvfb-run on headless servers:
**Windows** — cargo binstall does not copy sidecar files (cargo-binstall#353), so the installed servo-fetch.exe fails at startup with a missing libEGL.dll. Download the .zip from Releases instead — it bundles libEGL.dll and libGLESv2.dll.
**macOS** — no extra setup needed.
Quick Start
CLI
Full CLI reference → servo-fetch-cli
Exit status
Batch fetch attempts every URL and exits non-zero for any fetch failure servo-fetch detects. Crawl exits non-zero for page failures only when every attempted page fails. Command-level failures remain fatal; a closed output pipe is treated as success. See the CLI exit-code reference for exact codes.