Headless Chrome可能要被替代了。

最近有个叫Obscura的开源项目,用Rust写了个无头浏览器,专为AI代理和大规模爬虫设计。数字很直接:
单二进制文件,不需要Node.js或Chrome运行时,也没外部依赖。部署就是下载一个70MB的文件。
反检测功能做得挺狠:
兼容Chrome DevTools Protocol,可以直接替换Puppeteer和Playwright里的Headless Chrome。
# Linux x86_64
curl -LO https://github.com/h4ckf0r0day/obscura/releases/latest/download/obscura-x86_64-linux.tar.gz
tar xzf obscura-x86_64-linux.tar.gz
./obscura fetch https://example.com --eval "document.title"
# macOS Apple Silicon
curl -LO https://github.com/h4ckf0r0day/obscura/releases/latest/download/obscura-aarch64-macos.tar.gz
tar xzf obscura-aarch64-macos.tar.gz
# macOS Intel
curl -LO https://github.com/h4ckf0r0day/obscura/releases/latest/download/obscura-x86_64-macos.tar.gz
tar xzf obscura-x86_64-macos.tar.gz# 获取页面标题
obscura fetch https://example.com --eval "document.title"
# 提取所有链接
obscura fetch https://example.com --dump links
# 渲染JavaScript并输出HTML
obscura fetch https://news.ycombinator.com --dump html
# 等待动态内容
obscura fetch https://example.com --wait-until networkidle0
# 并行爬取
obscura scrape url1 url2 url3 ... \
--concurrency 25 \
--eval "document.querySelector('h1').textContent" \
--format jsonobscura serve --port 9222
# 启用隧道模式
obscura serve --port 9222 --stealthimport { chromium } from 'playwright-core';
const browser = await chromium.connectOverCDP({
endpointURL: 'ws://127.0.0.1:9222',
});
const page = await browser.newContext().then(ctx => ctx.newPage());
await page.goto('https://en.wikipedia.org/wiki/Web_scraping');
console.log(await page.title());
await browser.close();对需要大量浏览器实例的AI代理来说,这意味着在相同硬件上能跑更多实例。32GB内存的服务器,原来最多跑160个Chrome实例,现在能跑1000多个。
项目用Apache-2.0许可证,支持Linux x86_64、macOS Apple Silicon和Intel平台。Rust在系统级工具上的优势开始显现了。
地址:https://github.com/h4ckf0r0day/obscura