--- name: l1-web-fetch description: "L1 原子技能:通用网页抓取。输入 URL,返回网页正文内容(Markdown 格式)。" layer: 1 domain: sensing keywords: - web - fetch - scrape - html - markdown input_schema: "{ url: string }" output_schema: "{ content: string, title: string, status: number }" --- # L1: Web Fetch(网页抓取原子技能) ## 能力 给定一个 URL,抓取网页内容并返回清洗后的正文(Markdown 格式)。 ## 使用方法 使用 `curl` 命令抓取网页内容。**本机出网不稳,参数收敛为 `--retry 1 --max-time 40`,不许省略** (详见 `docs/SKILL.md` §外网访问 SOP;2026-08-28 实测 `--retry 3 --max-time 60` 会把慢主机单条 URL 放大到 4 分钟以上,已弃用): ```bash # 基础抓取(返回原始 HTML)—— --retry 1 --max-time 40 必须齐全 curl -sSL --retry 1 --max-time 40 -H "User-Agent: Mozilla/5.0" "" # 如果需要转为纯文本/Markdown(去除 HTML 标签) curl -sSL --retry 1 --max-time 40 -H "User-Agent: Mozilla/5.0" "" | python3 -c " import sys, re html = sys.stdin.read() # 去除 script/style html = re.sub(r'<(script|style)[^>]*>.*?', '', html, flags=re.DOTALL|re.IGNORECASE) # 转换常见标签 html = re.sub(r'', '\n', html, flags=re.IGNORECASE) html = re.sub(r']*>', '\n\n', html, flags=re.IGNORECASE) html = re.sub(r']*>(.*?)', lambda m: '#'*int(m.group(1))+' '+m.group(2)+'\n', html, flags=re.IGNORECASE) html = re.sub(r']*>', '- ', html, flags=re.IGNORECASE) # 去除剩余标签 text = re.sub(r'<[^>]+>', '', html) # 清理多余空行 text = re.sub(r'\n{3,}', '\n\n', text).strip() print(text[:5000]) " ``` ## 输入 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | url | string | ✅ | 目标网页 URL | ## 输出 返回网页正文内容(Markdown 格式),截取前 5000 字符。 ## 约束 - 超时:40 秒上限(`--max-time 40`),重试固定 1 次(`--retry 1`) - 最大返回:5000 字符 - 不支持需要 JavaScript 渲染的 SPA 页面 - 遇到 403/429 错误时应报告"目标网站拒绝访问" - **假 200 复核**:HTTP 200 不代表内容有效 —— 必须查 `` / grep 关键词复核; `docs.claude.com` 有区域封锁假 200 页(不同 URL 返回字节级相同内容),复核不过关一律进 blocked_sources - **失败降级**:curl 失败 → 换镜像域再试一次(GitHub 文件走 `cdn.jsdelivr.net/gh/<org>/<repo>@<branch>/<path>`, raw.githubusercontent 直连实测不可达)→ 改用 `WebFetch` 再试一次 → 仍失败则标注 「无法复检(URL + 时间戳)」并继续,❌ 禁止因抓取失败重跑整轮训练 - **缓存优先**:官方参考文档首抓成功后必须把原文 + sha256 落盘到 `train/hunt/sources_*.json`, 后续轮次只读缓存、不再复抓