bdsearch
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesebdsearch
bdsearch
封装 命令行工具,用于百度网页搜索。
bdsearchEncapsulates the command-line tool for Baidu web search.
bdsearch核心能力
Core Capabilities
- 网页搜索 - 查询公开网页与资讯内容
- 时间过滤 - 支持最近一天、一周、一月、一年或自定义日期范围
- 多格式输出 - 支持 JSON、Markdown、表格
- 配置管理 - 支持 API Key 配置与默认参数管理
- Web Search - Query public web pages and news content
- Time Filtering - Supports the latest day, week, month, year, or custom date range
- Multi-format Output - Supports JSON, Markdown, and table formats
- Configuration Management - Supports API Key configuration and default parameter management
工作流程
Workflow
🔍 执行网页搜索
🔍 Execute Web Search
当用户表达搜索、查资料、查新闻、做调研意图时,尝试执行如下搜索命令:
bash
bdsearch "关键词" --format json --count 10视需要也可以使用如下常见用法:
bash
bdsearch "人工智能" --count 10 --format json # 搜索关键词,返回前10条结果,格式为JSON
bdsearch "最新新闻" --freshness pd --format json # 搜索最近一天的新闻,格式为JSON
bdsearch "科技新闻" --freshness "2025-09-01to2025-09-08" --format markdown # 搜索指定日期范围的新闻,格式为MarkdownWhen users express intentions of searching, looking up information, checking news, or conducting research, try executing the following search command:
bash
bdsearch "关键词" --format json --count 10Common usages can also be applied as needed:
bash
bdsearch "人工智能" --count 10 --format json # Search keywords, return top 10 results in JSON format
bdsearch "最新新闻" --freshness pd --format json # Search news from the latest day in JSON format
bdsearch "科技新闻" --freshness "2025-09-01to2025-09-08" --format markdown # Search news within the specified date range in Markdown format🛠️ 错误排查
🛠️ Troubleshooting
如果执行失败,首先检查是否安装 ,以及是否正确配置了百度 API Key。可以按照以下步骤进行排查:
bdsearch1. 检查安装 → 2. 检查认证配置 Step 1: 检查是否安装 bdsearch
bash
command -v bdsearch如果未安装,执行:
bash
npm install -g @lyhue1991/bdsearchStep 2: 检查认证配置
检查本地配置:
bash
bdsearch config --show如果未配置,检查环境变量:
bash
printenv BAIDU_API_KEY如果仍然未配置,则需要用户提供百度 API Key,然后执行:
bash
bdsearch config --api-key "你的APIKey"If execution fails, first check if is installed and if the Baidu API Key is configured correctly. Follow these steps for troubleshooting:
bdsearch1. Check Installation → 2. Check Authentication ConfigurationStep 1: Check if bdsearch is installed
bash
command -v bdsearchIf not installed, execute:
bash
npm install -g @lyhue1991/bdsearchStep 2: Check Authentication Configuration
Check local configuration:
bash
bdsearch config --showIf not configured, check environment variables:
bash
printenv BAIDU_API_KEYIf still not configured, ask the user for the Baidu API Key and execute:
bash
bdsearch config --api-key "你的APIKey"⚙️ 配置 bdsearch
⚙️ Configure bdsearch
当用户只需配置 API Key 或默认参数时:
bash
bdsearch config --api-key "你的APIKey"
bdsearch config --default-format json --default-count 10 --default-freshness pd查看当前配置:
bash
bdsearch config --show重置配置:
bash
bdsearch config --resetWhen users only need to configure the API Key or default parameters:
bash
bdsearch config --api-key "你的APIKey"
bdsearch config --default-format json --default-count 10 --default-freshness pdView current configuration:
bash
bdsearch config --showReset configuration:
bash
bdsearch config --reset📰 查询最近内容
📰 Query Latest Content
当用户明确要“最新”“最近几天”“本周”的内容时,优先使用时间过滤:
bash
bdsearch "AI 新闻" --freshness pd --format json
bdsearch "大模型进展" --freshness pw --format jsonWhen users explicitly request "latest", "recent days", or "this week" content, prioritize using time filtering:
bash
bdsearch "AI 新闻" --freshness pd --format json
bdsearch "大模型进展" --freshness pw --format json📄 输出适合阅读的结果
📄 Output Reader-friendly Results
当用户需要直接阅读或复制结果时:
bash
bdsearch "Node.js" --format markdown
bdsearch "Python" --count 10 --format tableWhen users need results for direct reading or copying:
bash
bdsearch "Node.js" --format markdown
bdsearch "Python" --count 10 --format table参数说明
Parameter Description
| 参数 | 说明 |
|---|---|
| 搜索关键词,必填 |
| 返回结果数量,范围 1-50,默认 10 |
| 时间过滤,支持 |
| 输出格式,支持 |
| Parameter | Description |
|---|---|
| Search keyword, required |
| Number of returned results, range 1-50, default 10 |
| Time filtering, supports |
| Output format, supports |
注意事项
Notes
- 优先用 JSON - 需要进一步分析、提取字段、总结内容时,优先使用
--format json - 认证要求 - 使用前必须配置 ,或通过
BAIDU_API_KEY保存本地配置bdsearch config --api-key - 结果可能重复 - 上游接口可能返回重复链接,必要时需要按 去重
url - 时间过滤建议 - 查询新闻或动态信息时,优先增加
--freshness
- Prioritize JSON - When further analysis, field extraction, or content summarization is needed, prioritize using
--format json - Authentication Requirement - Must configure before use, or save local configuration via
BAIDU_API_KEYbdsearch config --api-key - Possible Duplicate Results - The upstream interface may return duplicate links; deduplication by is necessary if needed
url - Time Filtering Suggestion - Prioritize adding when querying news or dynamic information
--freshness
快速参考
Quick Reference
bash
undefinedbash
undefined查看帮助
View help
bdsearch --help
bdsearch config --help
bdsearch --help
bdsearch config --help
查看配置
View configuration
bdsearch config --show
bdsearch config --show
设置 API Key
Set API Key
bdsearch config --api-key "你的APIKey"
bdsearch config --api-key "你的APIKey"
基础搜索
Basic search
bdsearch "人工智能" --format json
bdsearch "人工智能" --format json
指定结果数量
Specify number of results
bdsearch "TypeScript 教程" --count 5 --format json
bdsearch "TypeScript 教程" --count 5 --format json
查询最近内容
Query latest content
bdsearch "最新新闻" --freshness pd --format json
bdsearch "最新新闻" --freshness pd --format json
自定义日期范围
Custom date range
bdsearch "科技新闻" --freshness "2025-09-01to2025-09-08" --format json
bdsearch "科技新闻" --freshness "2025-09-01to2025-09-08" --format json
适合阅读的输出
Reader-friendly output
bdsearch "Node.js" --format markdown
bdsearch "Python" --format table
undefinedbdsearch "Node.js" --format markdown
bdsearch "Python" --format table
undefined