AgentSkillsCN

web-search

默认采用 DuckDuckGo API 进行网络搜索;若提供了 TRAVILY_TOKEN,则会回退至 Tavily API。当您需要搜索实时信息、开展课题研究、查找相关链接,或从在线资源中获取数据时,可优先选用此功能。支持新闻资讯、技术资料、学术论文、企业数据,以及各类通用网络内容的查询需求。

SKILL.md
--- frontmatter
name: web-search
description: Web search capability using DuckDuckGo API by default, with Tavily API fallback when TRAVILY_TOKEN is provided. Use when you need to search the web for current information, research topics, find URLs, or gather data from online sources. Supports queries for news, technical information, research papers, company data, and general web content.

Web Search

Quick Start

Search the web using the included script:

bash
python3 /skills/web-search/scripts/web_search.py "your search query" [max_results]

Example:

bash
python3 /skills/web-search/scripts/web_search.py "latest AI research" 5

Search Methods

DuckDuckGo API (Default)

  • No setup required - works out of the box
  • Uses DuckDuckGo's Instant Answer API
  • Returns structured results with titles and URLs
  • Good for general searches and research

Tavily API (Premium)

  • Setup required - set TRAVILY_TOKEN environment variable
  • Higher quality results with direct answers
  • Better for complex queries and research
  • Structured JSON response with content snippets

To use Tavily:

bash
export TRAVILY_TOKEN="your-tavily-api-token"
python3 /skills/web-search/scripts/web_search.py "your query"

Output Format

Both methods return JSON:

json
[
  {
    "title": "Result Title",
    "url": "https://example.com",
    "content": "Optional content (Tavily only)"
  }
]

Use Cases

  • Research: Find current information on topics
  • URL Discovery: Find relevant websites and resources
  • Fact Checking: Verify information from multiple sources
  • Technical Documentation: Find official docs and references
  • News & Updates: Get current events and developments

Integration with Scripts

The web search can be integrated into other scripts:

python
import subprocess
import json

def search_and_extract(query, max_results=5):
    result = subprocess.run(
        ['python3', '/skills/web-search/scripts/web_search.py', query, str(max_results)],
        capture_output=True,
        text=True
    )
    return json.loads(result.stdout)

Resources

  • Script: /skills/web-search/scripts/web_search.py - Main search script
  • Reference: /skills/web-search/references/search_methods.md - Detailed method documentation