SKILL.md
1.75 KB
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 命令抓取网页内容:
# 基础抓取(返回原始 HTML)
curl -sL --max-time 15 -H "User-Agent: Mozilla/5.0" "<URL>"
# 如果需要转为纯文本/Markdown(去除 HTML 标签)
curl -sL --max-time 15 -H "User-Agent: Mozilla/5.0" "<URL>" | python3 -c "
import sys, re
html = sys.stdin.read()
# 去除 script/style
html = re.sub(r'<(script|style)[^>]*>.*?</\1>', '', html, flags=re.DOTALL|re.IGNORECASE)
# 转换常见标签
html = re.sub(r'<br\s*/?>', '\n', html, flags=re.IGNORECASE)
html = re.sub(r'<p[^>]*>', '\n\n', html, flags=re.IGNORECASE)
html = re.sub(r'<h(\d)[^>]*>(.*?)</h\1>', lambda m: '#'*int(m.group(1))+' '+m.group(2)+'\n', html, flags=re.IGNORECASE)
html = re.sub(r'<li[^>]*>', '- ', 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 字符。
约束
- 超时:15 秒
- 最大返回:5000 字符
- 不支持需要 JavaScript 渲染的 SPA 页面
- 遇到 403/429 错误时应报告"目标网站拒绝访问"