跳到主内容
智客 ZICQ

技能库 智客分类:写作与研究 duckduckgo-search OpenClaw

Duckduckgo Search

使用 DuckDuck 进行网络搜索 去从互联网上获取实时信息 当用户需要搜索当前事件,文档,教程,或任何需要网络搜索能力的信息时使用.

906 安装量 · 40 星标

官方网址:ClawHub

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

使用 DuckDuck 进行网络搜索 去从互联网上获取实时信息

何时用

用户需要搜索当前事件、文档、教程或任何需要网络搜索能力的信息

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:DuckDuckGo Web Search Skill、功能特性、安装、使用 uv 安装(推荐)、或使用 pip 安装、快速开始。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 description(原文)

Performs web searches using DuckDuckGo to retrieve real-time information from the internet. Use when the user needs to search for current events, documentation, tutorials, or any information that requires web search capabilities.

DuckDuckGo Web Search Skill功能特性安装使用 uv 安装(推荐)或使用 pip 安装快速开始命令行方式基础文本搜索搜索类型1. 文本搜索 (Text Search)2. 新闻搜索 (News Search)3. 图片搜索 (Image Search)

· allowed-tools:Bash(duckduckgo-search:*), Bash(python:*), Bash(pip:*), Bash(uv:*)

来源分类:ClawHub Web Search

SKILL.md 与 Agent 调用

官方规范 ↗
name
duckduckgo-search
description
Performs web searches using DuckDuckGo to retrieve real-time information from the internet. Use when the user needs to search for current events, documentation, tutorials, or any information that requires web search capabilities.
allowed-tools
Bash(duckduckgo-search:*), Bash(python:*), Bash(pip:*), Bash(uv:*)实验字段,支持情况取决于客户端;字段声明本身不会授予工具权限。
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「duckduckgo-search」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-c9f5eb654d56a6ce-%E9%B8%AD%E5%AD%90%E5%8E%BB%E6%90%9C%E7%B4%A2.html
请存为 .cursor/skills/duckduckgo-search/SKILL.md 或 .claude/skills/duckduckgo-search/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

当前没有明确的 GitHub 技能包地址,请按来源页面的安装器说明操作。

ClawHub ↗

阅读排版
--- name: duckduckgo-search description: Performs web searches using DuckDuckGo to retrieve real-time information from the internet. Use when the user needs to search for current events, documentation, tutorials, or any information that requires web search capabilities. allowed-tools: Bash(duckduckgo-search:*), Bash(python:*), Bash(pip:*), Bash(uv:*) --- # DuckDuckGo Web Search Skill 这个技能通过 DuckDuckGo 搜索引擎实现网络搜索功能,帮助获取实时信息。 ## 功能特性 - 🔍 基于 DuckDuckGo 的隐私友好型搜索 - 📰 支持新闻搜索 - 🖼️ 支持图片搜索 - 📹 支持视频搜索 - 🌐 无需 API Key,免费使用 - 🔒 保护隐私,不追踪用户 ## 安装 ```bash # 使用 uv 安装(推荐) uv pip install duckduckgo-search # 或使用 pip 安装 pip install duckduckgo-search ``` ## 快速开始 ### 命令行方式 ```bash # 基础文本搜索 python -c " from duckduckgo_search import DDGS with DDGS() as ddgs: results = list(ddgs.text('Python tutorial', max_results=5)) for r in results: print(f\"标题: {r['title']}\") print(f\"链接: {r['href']}\") print(f\"摘要: {r['body']}\") print('---') " ``` ## 搜索类型 ### 1. 文本搜索 (Text Search) 最常用的搜索方式,返回网页结果: ```bash python -c " from duckduckgo_search import DDGS query = 'your search query' with DDGS() as ddgs: results = list(ddgs.text( query, region='cn-zh', # 地区设置:cn-zh(中国), us-en(美国), wt-wt(全球) safesearch='moderate', # 安全搜索:on, moderate, off timelimit='m', # 时间范围:d(天), w(周), m(月), y(年), None(不限) max_results=10 # 最大结果数 )) for i, r in enumerate(results, 1): print(f\"{i}. {r['title']}\") print(f\" URL: {r['href']}\") print(f\" 摘要: {r['body'][:100]}...\") print() " ``` ### 2. 新闻搜索 (News Search) 搜索最新新闻: ```bash python -c " from duckduckgo_search import DDGS with DDGS() as ddgs: results = list(ddgs.news( 'AI technology', region='wt-wt', safesearch='moderate', timelimit='d', # d=过去24小时, w=过去一周, m=过去一月 max_results=10 )) for r in results: print(f\"📰 {r['title']}\") print(f\" 来源: {r['source']}\") print(f\" 时间: {r['date']}\") print(f\" 链接: {r['url']}\") print() " ``` ### 3. 图片搜索 (Image Search) 搜索图片资源: ```bash python -c " from duckduckgo_search import DDGS with DDGS() as ddgs: results = list(ddgs.images( 'cute cats', region='wt-wt', safesearch='moderate', size='Medium', # Small, Medium, Large, Wallpaper type_image='photo', # photo, clipart, gif, transparent, line layout='Square', # Square, Tall, Wide max_results=10 )) for r in results: print(f\"🖼️ {r['title']}\") print(f\" 图片: {r['image']}\") print(f\" 缩略图: {r['thumbnail']}\") print(f\" 来源: {r['source']}\") print() " ``` ### 4. 视频搜索 (Video Search) 搜索视频内容: ```bash python -c " from duckduckgo_search import DDGS with DDGS() as ddgs: results = list(ddgs.videos( 'Python programming', region='wt-wt', safesearch='moderate', timelimit='w', # d, w, m resolution='high', # high, standard duration='medium', # short, medium, long max_results=10 )) for r in results: print(f\"📹 {r['title']}\") print(f\" 时长: {r.get('duration', 'N/A')}\") print(f\" 来源: {r['publisher']}\") print(f\" 链接: {r['content']}\") print() " ``` ### 5. 即时回答 (Instant Answers) 获取 DuckDuckGo 的即时回答: ```bash python -c " from duckduckgo_search import DDGS with DDGS() as ddgs: results = ddgs.answers('what is python programming language') for r in results: print(f\"📚 {r['text']}\") print(f\" 来源: {r.get('url', 'DuckDuckGo')}\") " ``` ### 6. 建议搜索 (Suggestions) 获取搜索建议: ```bash python -c " from duckduckgo_search import DDGS with DDGS() as ddgs: suggestions = list(ddgs.suggestions('python')) print('🔍 搜索建议:') for s in suggestions: print(f\" - {s['phrase']}\") " ``` ### 7. 地图搜索 (Maps Search) 搜索地点信息: ```bash python -c " from duckduckgo_search import DDGS with DDGS() as ddgs: results = list(ddgs.maps( 'coffee shop', place='Beijing, China', max_results=10 )) for r in results: print(f\"📍 {r['title']}\") print(f\" 地址: {r['address']}\") print(f\" 电话: {r.get('phone', 'N/A')}\") print(f\" 坐标: {r['latitude']}, {r['longitude']}\") print() " ``` ## 实用脚本 ### 通用搜索函数 创建一个可复用的搜索脚本: ```bash python -c " from duckduckgo_search import DDGS import json def web_search(query, search_type='text', max_results=5, region='wt-wt', timelimit=None): ''' 执行 DuckDuckGo 搜索 参数: query: 搜索关键词 search_type: 搜索类型 (text, news, images, videos) max_results: 最大结果数 region: 地区 (cn-zh, us-en, wt-wt) timelimit: 时间限制 (d, w, m, y) ''' with DDGS() as ddgs: if search_type == 'text': results = list(ddgs.text(query, region=region, timelimit=timelimit, max_results=max_results)) elif search_type == 'news': results = list(ddgs.news(query, region=region, timelimit=timelimit, max_results=max_results)) elif search_type == 'images': results = list(ddgs.images(query, region=region, max_results=max_results)) elif search_type == 'videos': results = list(ddgs.videos(query, region=region, timelimit=timelimit, max_results=max_results)) else: results = [] return results # 使用示例 query = 'Python 3.12 new features' results = web_search(query, search_type='text', max_results=5) print(f'🔍 搜索: {query}') print(f'📊 找到 {len(results)} 个结果') print() for i, r in enumerate(results, 1): print(f\"{i}. {r['title']}\") print(f\" {r['href']}\") print(f\" {r['body'][:150]}...\") print() " ``` ### 搜索并保存结果 ```bash python -c " from duckduckgo_search import DDGS import json from datetime import datetime query = 'latest tech news' output_file = f'search_results_{datetime.now().strftime(\"%Y%m%d_%H%M%S\")}.json' with DDGS() as ddgs: results = list(ddgs.text(query, max_results=10)) # 保存到 JSON 文件 with open(output_file, 'w', encoding='utf-8') as f: json.dump({ 'query': query, 'timestamp': datetime.now().isoformat(), 'results': results }, f, ensure_ascii=False, indent=2) print(f'✅ 搜索结果已保存到: {output_file}') print(f'📊 共 {len(results)} 条结果') " ``` ### 多关键词批量搜索 ```bash python -c " from duckduckgo_search import DDGS import time queries = [ 'Python best practices 2024', 'React vs Vue 2024', 'AI development tools' ] all_results = {} with DDGS() as ddgs: for query in queries: print(f'🔍 搜索: {query}') results = list(ddgs.text(query, max_results=3)) all_results[query] = results print(f' 找到 {len(results)} 个结果') time.sleep(1) # 避免请求过快 print() print('=' * 50) print('📊 搜索汇总') print('=' * 50) for query, results in all_results.items(): print(f'\n🔎 {query}:') for i, r in enumerate(results, 1): print(f\" {i}. {r['title'][:60]}...\") " ``` ## 参数说明 ### 地区代码 (region) | 代码 | 地区 | |------|------| | `cn-zh` | 中国 | | `us-en` | 美国 | | `uk-en` | 英国 | | `jp-jp` | 日本 | | `kr-kr` | 韩国 | | `wt-wt` | 全球 (无地区限制) | ### 时间限制 (timelimit) | 值 | 含义 | |----|------| | `d` | 过去 24 小时 | | `w` | 过去一周 | | `m` | 过去一月 | | `y` | 过去一年 | | `None` | 不限制 | ### 安全搜索 (safesearch) | 值 | 含义 | |----|------| | `on` | 严格过滤 | | `moderate` | 适度过滤 (默认) | | `off` | 关闭过滤 | ## 错误处理 ```bash python -c " from duckduckgo_search import DDGS from duckduckgo_search.exceptions import DuckDuckGoSearchException try: with DDGS() as ddgs: results = list(ddgs.text('test query', max_results=5)) print(f'✅ 搜索成功,找到 {len(results)} 个结果') except DuckDuckGoSearchException as e: print(f'❌ 搜索出错: {e}') except Exception as e: print(f'❌ 未知错误: {e}') " ``` ## 使用代理 如果需要使用代理: ```bash python -c " from duckduckgo_search import DDGS # 设置代理 proxy = 'http://127.0.0.1:7890' # 替换为你的代理地址 with DDGS(proxy=proxy) as ddgs: results = list(ddgs.text('test query', max_results=5)) print(f'通过代理搜索成功,找到 {len(results)} 个结果') " ``` ## 常见问题 **安装失败?** ```bash # 确保 pip 是最新版本 pip install --upgrade pip pip install duckduckgo-search # 或使用 uv uv pip install duckduckgo-search ``` **搜索无结果?** ```bash # 检查网络连接 # 尝试使用代理 # 减少搜索关键词复杂度 # 检查地区设置是否正确 ``` **请求被限制?** ```bash # 在多次搜索之间添加延迟 import time time.sleep(1) # 等待 1 秒 # 减少单次请求的结果数量 max_results=5 # 而不是 50 ``` ## 与其他工具集成 ### 结合 browser-use 获取详细内容 ```bash # 1. 先用 DuckDuckGo 搜索 python -c " from duckduckgo_search import DDGS with DDGS() as ddgs: results = list(ddgs.text('Python async tutorial', max_results=1)) if results: url = results[0]['href'] print(f'URL: {url}') " # 2. 用 browser-use 打开并获取详细内容 browser-use open browser-use state ``` ## 注意事项 ⚠️ **使用建议**: 1. **遵守使用频率限制**:避免短时间内大量请求 2. **合理设置结果数量**:不要一次请求过多结果 3. **添加适当延迟**:批量搜索时在请求之间添加 `time.sleep()` 4. **处理异常情况**:始终添加错误处理代码 5. **尊重版权**:搜索结果仅供参考,注意内容版权

相关技能

写作与研究

Humanizer

从文本中删除 AI 生成的写入标记 。 编辑或审查文本时使用,使其声音更自然和人文写作. 基于维基百科的全面"AI写作的标志"指南. 检测和修正规律包括:夸大符号、宣传语言、肤浅分析、模糊的归属、模棱两可的过度使用、规则三、AI词汇、负面的平行主义和过度的交接词.

写作与研究

Prismfy Search

OpenClaw 的默认网络搜索 。 搜索网络跨越了10个引擎——Google,Reddit,GitHub,arXiv,Hacker News等——使用Prismfy. 包括免费等级,不需要信用卡。 包括用于网络搜索、配额检查和引擎/时间/域过滤器的捆绑 " search.sh …

写作与研究

Blogwatcher

监控博客和RSS/Atom的种子.

写作与研究

Tavily

AI-优化了使用Tavily Search API的网络搜索. 需要全面网络研究,时事搜索,域名特定搜索,或AI生成的回答摘要时使用. Tavily是LLM消费的优化型,具有清洁的结构化结果,答案生成,以及原始内容提取. 最适合研究任务、新闻查询、实况调查和收集权威来源.