CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

htmlq

$ htmlq 社区开源 低风险
Michael Farrell (mgdm) · 浏览器与网页抓取 · MIT · macos / linux / windows

htmlq 从标准输入解析 HTML,借助 CSS 选择器(如 article p、a 或 meta[name=description])配合 --text 或 --attribute 提取匹配内容,帮助 Agent 在读取前剔除数兆网页模板噪音。

FCRS-1.0 综合评分
89 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install htmlq
CLI vs MCP 选型建议 仅 CLI 可用

离线 Unix 管道过滤器(curl ... | htmlq --text 'main'),零网络与 MCP 开销即可大幅压缩网页 Token。

Agent 友好度体检单

— 原生 JSON 输出
✓ 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
✓ 只读模式开关
✓ 支持 NO_COLOR
— 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 21 / 25

零噪音管道工具,支持 --text、--attribute 与 --remove-nodes,但输出为纯文本或 HTML 片段而非 JSON。

  • Supports --text, --attribute, --remove-nodes, and -b base URL resolution
安全与权限边界 25 / 25

严格离线只读 HTML 解析器,无网络访问、不执行 JS、无任何凭据接触。

  • Pure offline stdin-to-stdout parser with no writes or network calls
安装与运行摩擦 14 / 15

静态单 Rust 二进制,可通过 brew、cargo 和 GitHub Releases 获取。

  • Zero-dependency Rust binary
能力覆盖与边际价值 14 / 15

与 curl 串联可在管道内将网页载荷缩减 10 至 50 倍。

  • Fast CSS selector extraction (--text, -a href)
维护与来源背书 7 / 10

社区 Rust 项目(mgdm/htmlq,MIT 协议),功能已趋于完善、更新频率较低。

  • mgdm/htmlq repository under MIT license
文档与可验证性 8 / 10

README 与 --help 简明直观。

  • Clear examples in mgdm/htmlq README

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

无需凭据;纯离线处理标准输入或本地文件。

潜在副作用
只读查询
费用与配额提示

免费开源(MIT 协议)Rust 二进制。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# htmlq Agent Rules
- Pipe `curl` HTML through `htmlq --text` or `--remove-nodes script --remove-nodes style` before inspecting web pages.
- `htmlq` is strictly static HTML parsing—it does not execute JavaScript on SPAs.

Agent 高频安全命令配方

只读查询(安全推荐)

从抓取的 HTML 页面提取纯正文
curl -fsS https://example.com | htmlq --text 'main, article, body'

使用 --text 剥离标签、脚本与导航框架,仅保留紧凑可读正文。

提取容器内的全部 href 链接
htmlq --attribute href 'main a' < page.html

从匹配的锚点元素中仅抽取 href 属性值(-a href)。

核心优势

  • + 纯离线、只读、毫秒级启动的 Rust HTML 过滤器。
  • + --text 与 --attribute 可高效剔除 HTML 冗余,显著节省上下文 Token。

注意事项与踩坑点

  • ! 仅解析静态 HTML,无法渲染客户端 JS 驱动的 SPA 页面。
  • ! 原生不直接输出 JSON。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI