首页 AI开发平台 ddgs:一个命令搜遍 Google、Bing、DuckDuckGo,AI Agent 也能用

ddgs:一个命令搜遍 Google、Bing、DuckDuckGo,AI Agent 也能用

📅 2026/6/2 👁 阅读 3 🔗 工具访问 1 次
ddgs:一个命令搜遍 Google、Bing、DuckDuckGo,AI Agent 也能用

工具地址

https://github.com/deedy5/ddgs

🚀 访问工具

ddgs:一个命令搜遍 Google、Bing、DuckDuckGo,AI Agent 也能用

做 AI 开发的人都知道,搜索能力是 Agent 的刚需。但大厂的搜索 API 要么收费、要么要注册、要么在国内用不了。

ddgs 是一个开源的 Python 元搜索库,一句话说清楚:装一个包,就能从 Google、Bing、DuckDuckGo、Brave、Yandex、Yahoo、Wikipedia 等多个搜索引擎同时搜,而且完全免费。

它原名 duckduckgo-search,后来改名为 ddgs(Dux Distributed Global Search),功能也从单一的 DuckDuckGo 搜索升级成了多引擎元搜索。

能搜什么

ddgs 覆盖了几乎所有常见的搜索类型:

而且它自动选择最优引擎,不需要你手动指定。

四种使用方式

1. Python 库

pip install ddgs
from ddgs import DDGS

results = DDGS().text("AI coding tools", max_results=5)
for r in results:
    print(r["title"], "->", r["href"])

支持文本、图片、视频、新闻、书籍五类搜索,每类都有对应的函数。

2. CLI 命令行

ddgs text -q "fastapi tutorial" -m 5
ddgs images -q "landscape photography" -m 10
ddgs news -q "AI regulation" -m 5 -t w
ddgs videos -q "python tutorial" -m 5 -o json

支持 JSON 输出,方便 pipe 给其他工具处理。

3. API 服务器

pip install ddgs[api]
ddgs api

启动后得到一个 FastAPI 服务,有 Swagger 文档界面。支持 docker-compose 一键部署。适合团队共享搜索能力。

4. MCP 服务器

pip install ddgs[mcp]
ddgs mcp

这玩意儿对 AI 开发者特别有用。MCP(Model Context Protocol)是 AI Agent 的标准工具协议。装好之后,Claude Desktop、Cursor、Cline 等 AI 客户端可以直接把 ddgs 当工具用:

// Cursor / Claude Desktop MCP 配置
{
  "mcpServers": {
    "ddgs": {
      "command": "ddgs",
      "args": ["mcp"]
    }
  }
}

配置完你的 AI 助手就能直接联网搜索了。

为什么对 AI 开发有用

很多 AI Agent 框架内置的搜索工具要么依赖第三方收费 API,要么配置复杂。ddgs 的优势很明显:

对比一下:Firecrawl 的搜索 API 要付费,SerpAPI 也要付费,Google Search API 要配置账号绑信用卡。ddgs 装好就能用,对个人开发者和团队做原型验证非常友好。

安装和使用

# 基础安装
pip install ddgs

# 带 API 服务器
pip install ddgs[api]

# 带 MCP 服务器
pip install ddgs[mcp]

# 搜索
ddgs text -q "最近的 AI 新闻" -m 5 -r cn-zh

Python 3.10 以上可用。

# Python 中使用
from ddgs import DDGS

with DDGS() as ddgs:
    # 多引擎文本搜索
    results = ddgs.text(
        "python async programming",
        region="us-en",
        safesearch="off",
        max_results=5
    )
    for r in results:
        print(f"{r['title']}: {r['href']}")

我的看法

ddgs 定位很清楚——给开发者和 AI Agent 一个免费、多引擎、开箱即用的搜索方案。它不做搜索结果的「质量优化」,也不做 AI 摘要,就是踏踏实实地把多个搜索引擎的结果聚合起来,给你干净的接口。

这种「小而美」的工具在 AI 时代反而很实用。尤其是 MCP 支持这一块,让 AI Agent 瞬间有了搜索能力,不用写胶水代码。如果你在做 AI Agent 开发、RAG 应用、或者只是需要一个免费的搜索 API,ddgs 值得装上试试。

💬 评论区 (0 条评论)

暂无评论,快来发表第一条评论吧!

📤 分享这篇文章

📌 相关推荐

微信扫码分享

打开微信扫一扫