SingleFile CLI
$ single-file 社区开源 低风险SingleFile CLI(single-file)可驱动无头 Chromium 或 Firefox 渲染动态 JavaScript 页面、等待懒加载图片完成,并将完整 DOM 与内联资源保存为单个独立 HTML 文件(single-file <url> page.html)。
npm install -g single-file-cli 可生成高保真、资源全内联的 JS 渲染单页 HTML 快照,这是常规 MCP 浏览器工具不提供的能力。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
支持完全无头非交互运行及 --dump-content 或文件输出,但缺少 JSON 状态摘要或结构化元数据输出。
- Non-interactive headless execution; supports
--dump-contentand file output
仅执行只读页面渲染与本地 HTML 写入;支持 --remove-hidden-elements 与 --block-scripts。
- Supports
--block-scriptsand explicit output file paths
可通过 npm/npx 跨 macOS、Linux 与 Windows 安装,但依赖 Playwright/Puppeteer 或本地 Chromium/Firefox。
- Requires local Chrome/Chromium or
--browser-executable-path
在将动态 JS 页面、SPA 与懒加载图片归档为单文件 HTML 方面拥有极高 DOM 还原度。
- Handles lazy images (
--load-deferred-images-max-idle-time) and SPAs
由 SingleFile 原作者(gildas-lormeau/single-file-cli)基于 AGPL-3.0-or-later 持续维护。
- Official SingleFile CLI project by Gildas Lormeau
README 与 --help 记录了浏览器路径、抓取与压缩相关参数。
- README documents
--browser-executable-pathand--browser-args
安全边界、鉴权与放权指南
支持按次传入 --browser-cookies-file 或 --http-headers,不保存持久化凭据。
基于 AGPL-3.0-or-later 开源免费;依赖本地已安装 Chromium/Chrome 或 Firefox 浏览器。
# SingleFile CLI Agent Rules - Always write to a file path (`single-file <url> out.html`) rather than `--dump-content` to avoid blowing up stdout context. - Pass `--browser-executable-path` if Chrome/Chromium is not auto-discovered. - Use `--browser-args='["--no-sandbox"]'` only inside isolated Linux containers when required.
Agent 高频安全命令配方
只读查询(安全推荐)
single-file --help
不启动浏览器即可列出浏览器路径、懒加载超时与资源内联相关参数。
受控写入与预演
single-file https://example.com page.html
无头渲染目标 URL 并把完整 DOM 与内联资源写入 page.html。
核心优势
- + 能高保真捕获经 JavaScript 渲染的 SPA 与懒加载媒体资源。
- + 输出单文件可移植 HTML,无需附带额外静态资源目录。
注意事项与踩坑点
- ! 依赖外部 Chrome/Chromium/Firefox 可执行文件,在无头 Linux 中常需显式传入
--browser-executable-path。 - ! 不输出用于状态或资源统计的 JSON 报告。