返回顶部
d

duckduckgo-searchDuckDuckGo搜索

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.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
23,252
下载量
免费
免费
40
收藏
概述
安装方式
版本历史

duckduckgo-search

DuckDuckGo 网页搜索技能

这个技能通过 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 websearch(query, searchtype=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, maxresults=maxresults))
elif search_type == news:
results = list(ddgs.news(query, region=region, timelimit=timelimit, maxresults=maxresults))
elif search_type == images:
results = list(ddgs.images(query, region=region, maxresults=maxresults))
elif search_type == videos:
results = list(ddgs.videos(query, region=region, timelimit=timelimit, maxresults=maxresults))
else:
results = []

return results

使用示例

query = Python 3.12 new features results = websearch(query, searchtype=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
outputfile = fsearchresults{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 -

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 duckduckgo-search-1776420003 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 duckduckgo-search-1776420003 技能

通过命令行安装

skillhub install duckduckgo-search-1776420003

下载

⬇ 下载 duckduckgo-search v1.0.0(免费)

文件大小: 4.24 KB | 发布时间: 2026-4-17 19:15

v1.0.0 最新 2026-4-17 19:15
- Initial release of DuckDuckGo Web Search skill.
- Enables real-time web, news, image, video, and map searches via DuckDuckGo.
- Supports direct usage in Bash and Python without API keys.
- Offers privacy-friendly, untracked searches with adjustable region, language, and safe search settings.
- Includes comprehensive usage examples and parameter explanations in both English and Chinese.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部