用于为 AI 智能体提供联网搜索能力,让其获取实时信息。项目仅依赖 Python 标准库,支持 Bing 文本搜索、网页正文抓取、图片搜索下载,无需代理,失败时容错降级,不中断智能体流程。
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 个月前 |
AgentWebSearch — Agent 联网搜索技能
为 AI 智能体(Agent)提供联网搜索能力,让 Agent 能获取实时信息。零依赖,仅用 Python 标准库。
特性
- ✅ 零第三方依赖:仅用 Python 标准库
urllib+re+json - ✅ 网页文本搜索:Bing 国内版,返回标题/URL/摘要
- ✅ 网页正文抓取:抓取任意 URL,提取纯文本
- ✅ 图片搜索下载:搜索主题图片并下载到本地
- ✅ 国内可用:无需代理
- ✅ 容错降级:搜索失败返回明确提示,不中断 Agent 流程
快速开始
文本搜索
python scripts/web_search.py search "人工智能最新进展" --limit 5
输出:
1. 人工智能发展现状与趋势
URL: https://...
摘要: ...
2. ...
网页抓取
python scripts/web_search.py fetch "https://example.com/article"
图片搜索下载
python scripts/web_search.py images "南京景点" --limit 3 --output ./images
Python 模块调用
from scripts.web_search import web_search, fetch_webpage, search_images
# 文本搜索
result = web_search("人工智能最新进展", limit=5)
# 网页抓取
text = fetch_webpage("https://example.com/article")
# 图片搜索(返回本地路径列表)
paths = search_images("南京景点", limit=3, output_dir="./images")
目录结构
AgentWebSearch/
├── SKILL.md # 技能定义(Agent 读取)
├── README.md # 使用说明
└── scripts/
└── web_search.py # 核心搜索脚本
功能说明
| 函数 | 说明 | 返回 |
|---|---|---|
web_search(query, limit) |
Bing 文本搜索 | 格式化文本 |
fetch_webpage(url) |
网页正文抓取 | 纯文本(最多 8000 字) |
search_images(query, limit, output_dir) |
图片搜索下载 | 本地路径列表 |
许可证
MIT