--- name: l1-search-engine description: "L1 原子技能:搜索引擎调用。通过命令行搜索获取结构化搜索结果。" layer: 1 domain: sensing keywords: - search - google - bing - query - web search input_schema: "{ query: string, num_results?: number }" output_schema: "{ results: [{ title: string, url: string, snippet: string }] }" --- # L1: Search Engine(搜索引擎原子技能) ## 能力 根据关键词执行网络搜索,返回标题、URL 和摘要列表。 ## 使用方法 ### 方法 1: 使用 curl + DuckDuckGo(无需 API Key) ```bash curl -sL "https://html.duckduckgo.com/html/?q=$(python3 -c "import urllib.parse; print(urllib.parse.quote('搜索关键词'))")" \ -H "User-Agent: Mozilla/5.0" | python3 -c " import sys, re html = sys.stdin.read() results = re.findall(r']*>(.*?).*?]*>(.*?)', html, re.DOTALL) for i, (url, title, snippet) in enumerate(results[:10], 1): title = re.sub(r'<[^>]+>', '', title).strip() snippet = re.sub(r'<[^>]+>', '', snippet).strip() print(f'{i}. {title}') print(f' URL: {url}') print(f' {snippet}\n') " ``` ### 方法 2: 使用 ddgr(如已安装) ```bash ddgr --num 5 --json "搜索关键词" 2>/dev/null ``` ### 方法 3: 使用 Google(备选) ```bash curl -sL "https://www.google.com/search?q=$(python3 -c "import urllib.parse; print(urllib.parse.quote('搜索关键词'))")&num=5" \ -H "User-Agent: Mozilla/5.0" ``` ## 输入 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | query | string | ✅ | 搜索关键词 | | num_results | number | ❌ | 返回结果数量,默认 5 | ## 输出 结构化的搜索结果列表,每条包含标题、URL、摘要。 ## 约束 - 默认返回前 5 条结果 - 优先使用 DuckDuckGo(无需 API Key) - 如果被限流,间隔 3 秒后重试一次