Install
openclaw skills install baidu-search-openclaw使用百度 AI 搜索 API 进行 Web 搜索。优先使用 API 模式,配额不足时自动切换到浏览器模式。支持中文搜索、新闻搜索等功能。
openclaw skills install baidu-search-openclaw使用百度 AI 搜索 API 或浏览器进行 Web 搜索。支持两种模式:
使用技能前需要设置百度千帆 API Key:
# Windows (PowerShell)
$env:BAIDU_API_KEY="your-api-key"
$env:PYTHONIOENCODING="utf-8"
# Linux/Mac
export BAIDU_API_KEY="your-api-key"
export PYTHONIOENCODING="utf-8"
API Key 获取地址:https://console.bce.baidu.com/qianfan/ais/console/apiKey
https://qianfan.baidubce.com/v2/ai_search/web_search# Windows
$env:PYTHONIOENCODING="utf-8"
python skills/baidu-search/scripts/search.py '{"query":"今日新闻"}'
# Linux/Mac
PYTHONIOENCODING=utf-8 python3 skills/baidu-search/scripts/search.py '{"query":"今日新闻"}'
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| query | string | 是 | - | 搜索关键词 |
| edition | string | 否 | standard | standard(完整版) 或 lite(轻量版) |
| resource_type_filter | array | 否 | web:20 | 资源类型过滤 |
| search_filter | object | 否 | - | 高级过滤条件 |
| block_websites | array | 否 | - | 排除的网站列表 |
| search_recency_filter | string | 否 | year | 时间过滤:week, month, semiyear, year |
| safe_search | bool | 否 | false | 严格内容过滤 |
# 先设置环境变量 (Windows)
$env:BAIDU_API_KEY = "your-api-key"
$env:PYTHONIOENCODING = "utf-8"
# 然后调用 API
$body = @{
messages = @(
@{content = "今日新闻"; role = "user"}
)
edition = "standard"
search_source = "baidu_search_v2"
resource_type_filter = @(
@{type = "web"; top_k = 10}
)
search_recency_filter = "week"
safe_search = $false
} | ConvertTo-Json -Depth 3
Invoke-RestMethod -Uri "https://qianfan.baidubce.com/v2/ai_search/web_search" `
-Method POST `
-Headers @{
"Authorization" = "Bearer $env:BAIDU_API_KEY"
"X-Appbuilder-From" = "openclaw"
"Content-Type" = "application/json"
} `
-Body $body
{
"query": "最新新闻",
"search_recency_filter": "week",
"search_filter": {
"match": {
"site": ["news.baidu.com"]
}
}
}
{
"query": "旅游景点",
"resource_type_filter": [
{"type": "web", "top_k": 20},
{"type": "video", "top_k": 5}
]
}
https://www.baidu.com/s?wd=关键词https://www.baidu.com/s?wd=关键词&tn=newsbrowser 工具的 open action 打开搜索 URLbrowser 工具的 snapshot action 获取搜索结果