关于 web-search
web-search 是通过 curl 查询本地 SearXNG 并解析搜索结果的技能。它支持按引擎、语言和时间筛选,并提供使用摘要或获取完整页面的建议。
主要功能
- 01使用 curl 搜索本地 SearXNG
- 02按引擎和语言筛选
- 03按时间范围筛选结果
- 04使用 Python 解析结果摘要
- 05提供安装和故障排查说明
适用场景
- 01按时间筛选近期新闻
- 02使用指定引擎搜索代码
- 03查找中文搜索结果
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ hachiman566/ miao-skills --skill web-search安装后在 Claude Code 中输入/web-search确认已加载。
附带文件scripts/setup.sh
详细介绍
SearXNG 搜索技能
**前提条件:**运行
bash skills/searxng/scripts/setup.sh,自动安装并启动 SearXNG(基于 Docker,幂等,可安全重复运行)。
搜索
通过 curl 查询本地 SearXNG 实例(优先使用此方式,因为 WebFetch 会阻止访问 localhost):
curl -s "http://localhost:8888/search?q=YOUR+QUERY&format=json"
常见变体:
# Target specific engines (reduces noise)
curl -s "http://localhost:8888/search?q=react+hooks&engines=google,bing&format=json"
# Filter by recency
curl -s "http://localhost:8888/search?q=openai+news&time_range=week&format=json"
# Chinese content
curl -s "http://localhost:8888/search?q=人工智能&engines=baidu,bing&lang=zh&format=json"
# Dev/code questions
curl -s "http://localhost:8888/search?q=rust+async+error&engines=stackoverflow,github&format=json"
使用 Python 解析结果(推荐):
curl -s "http://localhost:8888/search?q=YOUR+QUERY&format=json" | \
python3 -c "import sys,json; data=json.load(sys.stdin); [print(f'- {r[\"title\"]}\n {r[\"url\"]}\n {r[\"content\"][:150]}') for r in data.get('results',[])[:5]]"
参数
| 参数 | 说明 | 值 |
|---|---|---|
q | 搜索查询 | URL 编码字符串 |
engines | 指定引擎 | google,bing,duckduckgo,stackoverflow,github,baidu,... |
lang | 语言 | zh、en、all |
pageno | 页码 | 1、2、... |
time_range | 时间范围筛选 | day、week、month、year |
safesearch | 安全搜索 | 0、1、2 |
最佳实践
**先阅读摘要,再获取页面内容。**每条结果都包含一个 content 字段,其中提供了相关摘录——通常可以直接找到答案。获取完整页面会消耗多得多的 token,因此只有在摘要内容不足时才这样做。
**最多查看排名前 3–5 条结果。**前几条结果几乎总是足够的。更多结果会消耗更多 token,却不会显著提升答案质量。
**根据任务选择搜索引擎。**缩小引擎范围可以减少干扰并加快结果返回:
- 代码/开发:
engines=stackoverflow,github - 中文内容:
engines=baidu,bing&lang=zh - 近期事件:追加
&time_range=week
如果 SearXNG 未运行
先运行设置脚本,然后重试:
bash skills/web-search/scripts/setup.sh
关于 WebFetch 的说明
请勿将 WebFetch 用于 SearXNG——由于 SSRF 防护,它会阻止所有本地/私有地址(localhost、127.0.0.1、192.168.x.x、[::1]、自定义 hosts 条目)。请始终通过 Bash 使用 curl。
说明
- 第一次请求可能较慢(引擎预热)
- 用于远程或生产环境时,请为 SearXNG 实例添加身份验证
评论
支持 Markdown