重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
duckducksearch by xsailor511/duckduck-web-search
npx skills add https://github.com/xsailor511/duckduck-web-search --skill duckducksearch此技能通过 duckduckgo-search Python 包,利用 DuckDuckGo 搜索引擎提供网络搜索功能。它支持文本、图片、视频和新闻搜索,并提供多种过滤选项。
pip install -U duckduckgo_search
from duckduckgo_search import DDGS
# 基本文本搜索
results = DDGS().text("python programming", max_results=10)
# 带过滤器的高级文本搜索
results = DDGS().text(
keywords="python programming",
region="us-en", # 区域:us-en, uk-en, cn-zh 等
safesearch="moderate", # on, moderate, off
timelimit="m", # d (天), w (周), m (月), y (年)
backend="auto", # auto, html, lite, bing
max_results=10
)
from duckduckgo_search import DDGS
results = DDGS().images(
keywords="butterfly",
region="wt-wt",
safesearch="off",
size=None, # Small, Medium, Large, Wallpaper
color="Monochrome", # 颜色过滤器
type_image=None, # photo, clipart, gif, transparent, line
layout=None, # Square, Tall, Wide
license_image=None, # any, Public, Share, ShareCommercially, Modify, ModifyCommercially
max_results=100
)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
from duckduckgo_search import DDGS
results = DDGS().videos(
keywords="cars",
region="wt-wt",
safesearch="off",
timelimit="w",
resolution="high", # high, standard
duration="medium", # short, medium, long
license_videos=None, # creativeCommon, youtube
max_results=50
)
from duckduckgo_search import DDGS
results = DDGS().news(
keywords="technology",
region="us-en",
safesearch="moderate",
timelimit="d", # d, w, m
max_results=20
)
| 区域代码 | 描述 |
|---|---|
| wt-wt | 全球 (无区域限制) |
| us-en | 美国 |
| uk-en | 英国 |
| cn-zh | 中国 |
| jp-jp | 日本 |
| kr-kr | 韩国 |
| de-de | 德国 |
| fr-fr | 法国 |
| in-en | 印度 |
| au-en | 澳大利亚 |
| ca-en | 加拿大 |
| br-pt | 巴西 |
| ru-ru | 俄罗斯 |
使用 DuckDuckGo 搜索运算符进行高级查询:
| 运算符 | 示例 | 描述 |
|---|---|---|
| 精确匹配 | "cats and dogs" | 搜索精确短语 |
| 排除 | cats -dogs | 排除术语 |
| 要求 | cats +dogs | 要求包含术语 |
| 文件类型 | cats filetype:pdf | 搜索 PDF、文档等 |
| 站点 | dogs site:example.com | 搜索特定站点 |
| 排除站点 | cats -site:example.com | 排除站点 |
| 标题包含 | intitle:dogs | 标题必须包含 |
| URL 包含 | inurl:cats | URL 必须包含 |
# 使用 Tor 浏览器
ddgs = DDGS(proxy="tb", timeout=20)
# 使用自定义代理
ddgs = DDGS(proxy="socks5://user:password@host:port", timeout=20)
# 通过环境变量
import os
os.environ["DDGS_PROXY"] = "socks5://user:password@host:port"
from duckduckgo_search import DDGS
from duckduckgo_search.exceptions import (
DuckDuckGoSearchException,
RatelimitException,
TimeoutException,
ConversationLimitException,
)
try:
results = DDGS().text("query", max_results=10)
except RatelimitException:
print("超出速率限制。请尝试使用代理或稍后重试。")
except TimeoutException:
print("请求超时。")
except DuckDuckGoSearchException as e:
print(f"搜索错误: {e}")
# 文本搜索
ddgs text -k "python tutorial"
# 带区域的搜索
ddgs text -k "news" -r cn-zh
# 搜索并保存到 CSV
ddgs text -k "research filetype:pdf" -m 50 -o results.csv
# 图片搜索
ddgs images -k "landscape" -m 100 -d
# 新闻搜索
ddgs news -k "technology" -m 50 -t d -o json
{
"title": "Page Title",
"href": "https://example.com",
"body": "Page description..."
}
{
"title": "Image Title",
"image": "https://original-image-url.jpg",
"thumbnail": "https://thumbnail-url.jpg",
"url": "https://source-page.com",
"height": 3860,
"width": 4044,
"source": "Bing"
}
{
"content": "https://youtube.com/watch?v=...",
"title": "Video Title",
"description": "Video description...",
"duration": "8:22",
"provider": "YouTube",
"published": "2024-07-03"
}
{
"date": "2024-07-03T16:25:22+00:00",
"title": "News Headline",
"body": "News article description...",
"url": "https://news-site.com/article",
"image": "https://image-url.jpg",
"source": "News Source Name"
}
使用上下文管理器 以正确清理资源:
with DDGS() as ddgs: results = ddgs.text("query")
设置合理的 max_results 以避免长时间等待
使用 region 参数 获取本地化结果
实现重试逻辑 以应对速率限制:
import time
for attempt in range(3):
try:
results = DDGS().text("query", max_results=10)
break
except RatelimitException:
time.sleep(2 ** attempt)
5. 使用代理 进行高容量搜索,以避免 IP 被封
ddgs (新版本请使用 pip install ddgs)每周安装次数
64
代码仓库
首次出现
2026年3月4日
安全审计
已安装于
codex64
gemini-cli64
github-copilot64
kimi-cli64
amp64
cline64
This skill provides web search capabilities using the DuckDuckGo search engine via the duckduckgo-search Python package. It enables text, image, video, and news searches with various filtering options.
pip install -U duckduckgo_search
from duckduckgo_search import DDGS
# Basic text search
results = DDGS().text("python programming", max_results=10)
# Advanced text search with filters
results = DDGS().text(
keywords="python programming",
region="us-en", # Region: us-en, uk-en, cn-zh, etc.
safesearch="moderate", # on, moderate, off
timelimit="m", # d (day), w (week), m (month), y (year)
backend="auto", # auto, html, lite, bing
max_results=10
)
from duckduckgo_search import DDGS
results = DDGS().images(
keywords="butterfly",
region="wt-wt",
safesearch="off",
size=None, # Small, Medium, Large, Wallpaper
color="Monochrome", # Color filters
type_image=None, # photo, clipart, gif, transparent, line
layout=None, # Square, Tall, Wide
license_image=None, # any, Public, Share, ShareCommercially, Modify, ModifyCommercially
max_results=100
)
from duckduckgo_search import DDGS
results = DDGS().videos(
keywords="cars",
region="wt-wt",
safesearch="off",
timelimit="w",
resolution="high", # high, standard
duration="medium", # short, medium, long
license_videos=None, # creativeCommon, youtube
max_results=50
)
from duckduckgo_search import DDGS
results = DDGS().news(
keywords="technology",
region="us-en",
safesearch="moderate",
timelimit="d", # d, w, m
max_results=20
)
| Region Code | Description |
|---|---|
| wt-wt | Worldwide (No region) |
| us-en | United States |
| uk-en | United Kingdom |
| cn-zh | China |
| jp-jp | Japan |
| kr-kr | Korea |
| de-de | Germany |
| fr-fr | France |
| in-en | India |
| au-en | Australia |
| ca-en | Canada |
| br-pt | Brazil |
| ru-ru | Russia |
Use DuckDuckGo search operators for advanced queries:
| Operator | Example | Description |
|---|---|---|
| Exact match | "cats and dogs" | Search for exact phrase |
| Exclude | cats -dogs | Exclude term |
| Require | cats +dogs | Require term |
| File type | cats filetype:pdf | Search PDFs, docs, etc. |
| Site | dogs site:example.com |
# Using Tor Browser
ddgs = DDGS(proxy="tb", timeout=20)
# Using custom proxy
ddgs = DDGS(proxy="socks5://user:password@host:port", timeout=20)
# Via environment variable
import os
os.environ["DDGS_PROXY"] = "socks5://user:password@host:port"
from duckduckgo_search import DDGS
from duckduckgo_search.exceptions import (
DuckDuckGoSearchException,
RatelimitException,
TimeoutException,
ConversationLimitException,
)
try:
results = DDGS().text("query", max_results=10)
except RatelimitException:
print("Rate limit exceeded. Try using a proxy or waiting.")
except TimeoutException:
print("Request timed out.")
except DuckDuckGoSearchException as e:
print(f"Search error: {e}")
# Text search
ddgs text -k "python tutorial"
# Search with region
ddgs text -k "news" -r cn-zh
# Search and save to CSV
ddgs text -k "research filetype:pdf" -m 50 -o results.csv
# Image search
ddgs images -k "landscape" -m 100 -d
# News search
ddgs news -k "technology" -m 50 -t d -o json
{
"title": "Page Title",
"href": "https://example.com",
"body": "Page description..."
}
{
"title": "Image Title",
"image": "https://original-image-url.jpg",
"thumbnail": "https://thumbnail-url.jpg",
"url": "https://source-page.com",
"height": 3860,
"width": 4044,
"source": "Bing"
}
{
"content": "https://youtube.com/watch?v=...",
"title": "Video Title",
"description": "Video description...",
"duration": "8:22",
"provider": "YouTube",
"published": "2024-07-03"
}
{
"date": "2024-07-03T16:25:22+00:00",
"title": "News Headline",
"body": "News article description...",
"url": "https://news-site.com/article",
"image": "https://image-url.jpg",
"source": "News Source Name"
}
Use context manager for proper resource cleanup:
with DDGS() as ddgs: results = ddgs.text("query")
Set reasonable max_results to avoid long wait times
Use region parameter for localized results
Implement retry logic for rate limiting:
import time
for attempt in range(3):
try:
results = DDGS().text("query", max_results=10)
break
except RatelimitException:
time.sleep(2 ** attempt)
5. Use proxies for high-volume searches to avoid IP blocks
ddgs (use pip install ddgs for newer version)Weekly Installs
64
Repository
First Seen
Mar 4, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
codex64
gemini-cli64
github-copilot64
kimi-cli64
amp64
cline64
lark-cli 共享规则:飞书资源操作指南与权限配置详解
41,800 周安装
数据分析工具analyze:SQL查询、数据可视化、业务报告生成
705 周安装
CRM自动化工作流:HubSpot/Salesforce/Pipedrive潜在客户管理、交易跟踪与多CRM同步
715 周安装
GitHub深度研究技能:多轮自动化技术调研与Markdown报告生成工具
713 周安装
MetaClaw 进化智能体:OpenAI 兼容代理,支持技能注入与持续学习
726 周安装
字节跳动Kickart营销素材生成器:AI短视频创作工具,一键生成抖音商品营销视频
712 周安装
Portless:用稳定.localhost域名替代端口号,解决开发端口冲突和记忆难题
734 周安装
| Search specific site |
| Exclude site | cats -site:example.com | Exclude site |
| In title | intitle:dogs | Title must contain |
| In URL | inurl:cats | URL must contain |