ax

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ax — the AI-era curl: fetch, discover, extract

ax — AI时代的curl:获取、探索、提取

One command:
ax <url|file|-> [selector] [flags]
. Never write regex over HTML, and never use bare curl (it returns nothing on empty bodies).
一个命令:
ax <url|file|-> [selector] [flags]
。再也不用在HTML上写正则表达式,也不用使用裸curl(它遇到空内容时会返回空值)。

Cheatsheet

速查表

sh
ax https://api.site.example/users                    # {status, ok, ms, headers, body} — never silent
ax https://api.site.example/users -H 'authorization: Bearer x' -X POST -d '{"a":1}'
sh
ax https://api.site.example/users                    # {status, ok, ms, headers, body} — 绝不会静默
ax https://api.site.example/users -H 'authorization: Bearer x' -X POST -d '{"a":1}'

curl reflexes work: -u -I -o -k -m --data-raw (and -L/-i/-s/-f are no-ops)

curl的常用参数均适用:-u -I -o -k -m --data-raw(而-L/-i/-s/-f为无效操作)

ax https://site.example --outline # discover: repeating structures ax https://site.example --locate 'some text' # discover: which selector holds this ax https://site.example '.card' --count # confirm a hypothesis ax https://site.example '.card' --row 'title=a, href=a@href, id=@data-id' ax https://site.example 'table' --table --where 'Stars >= 30000' ax https://site.example 'table' --table --where '
Col With Spaces
~ /x/' ax https://docs.site.example/guide --md --budget 800 # read docs as markdown

The workflow: fetch/--outline once → --locate/--count to confirm → ONE
--row/--table call. Repeat fetches of the same URL are cached ~2min, so
probing is free (--fresh to bypass).
ax https://site.example --outline # 探索:重复结构 ax https://site.example --locate 'some text' # 探索:定位包含该文本的选择器 ax https://site.example '.card' --count # 验证假设 ax https://site.example '.card' --row 'title=a, href=a@href, id=@data-id' ax https://site.example 'table' --table --where 'Stars >= 30000' ax https://site.example 'table' --table --where '
Col With Spaces
~ /x/' ax https://docs.site.example/guide --md --budget 800 # 将文档以Markdown格式读取

工作流程:先执行一次获取/--outline → 用--locate/--count确认 → 执行一次--row/--table调用。同一URL的重复请求会被缓存约2分钟,因此探测无需额外成本(使用--fresh可绕过缓存)。

Speed discipline

速度准则

Aim for ≤3 tool calls: one batched look (
ax URL --outline; ax URL '.guess' --count
), one extraction call, then answer. Turns cost more than commands — semicolons are free. Every --row/--table run prints
N rows extracted
+ empty-field counts on stderr — that IS the verification; do not re-probe. Answer with the data, concisely — no methodology narration.
目标是使用≤3次工具调用:一次批量查看(
ax URL --outline; ax URL '.guess' --count
),一次提取调用,然后给出结果。转换操作的成本高于命令执行 —— 分号是免费的。每次--row/--table运行都会在标准错误输出中打印
N rows extracted
以及空字段计数 —— 这就是验证;无需重新探测。 简洁地返回数据即可 —— 无需说明方法流程。

Output rules

输出规则

  • Default cap 50 results; stderr announces anything hidden.
    --limit
    ,
    --all
    ,
    --budget <tokens>
    control it. Rows default to token-cheap TSV; add
    --json
    if you need JSON.
  • Errors are one stderr line with a hint — fix the flag, not the approach.
  • For plain text files and non-web work, use your usual tools — ax is for the web.
  • 默认最多返回50条结果;标准错误输出会提示隐藏的内容。
    --limit
    --all
    --budget <tokens>
    可控制结果数量。行默认采用低令牌消耗的TSV格式;如果需要JSON格式,添加
    --json
    参数即可。
  • 错误信息为标准错误输出中的一行提示 —— 修正参数即可,无需调整方法。
  • 对于纯文本文件和非网页相关工作,请使用你常用的工具 —— ax专为网页场景设计。