brave-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBrave Search
Brave Search
Web search and content extraction using the official Brave Search API. No browser required.
通过官方Brave Search API实现网页搜索与内容提取,无需浏览器。
Setup
配置步骤
Requires a Brave Search API account with a free subscription. A credit card is required to create the free subscription (you won't be charged).
- Create an account at https://api-dashboard.search.brave.com/register
- Create a "Free AI" subscription
- Create an API key for the subscription
- Add to your shell profile (or
~/.profilefor zsh):~/.zprofilebashexport BRAVE_API_KEY="your-api-key-here" - Install dependencies (run once):
bash
cd {baseDir} npm install
需要拥有一个带有免费订阅的Brave Search API账户。创建免费订阅需提供信用卡信息,但不会产生扣费。
- 在https://api-dashboard.search.brave.com/register创建账户
- 创建“Free AI”订阅
- 为该订阅生成API密钥
- 将密钥添加到你的Shell配置文件中(zsh用户为~/.profile或~/.zprofile):
bash
export BRAVE_API_KEY="your-api-key-here" - 安装依赖(只需运行一次):
bash
cd {baseDir} npm install
Search
搜索功能
bash
{baseDir}/search.js "query" # Basic search (5 results)
{baseDir}/search.js "query" -n 10 # More results (max 20)
{baseDir}/search.js "query" --content # Include page content as markdown
{baseDir}/search.js "query" --freshness pw # Results from last week
{baseDir}/search.js "query" --freshness 2024-01-01to2024-06-30 # Date range
{baseDir}/search.js "query" --country DE # Results from Germany
{baseDir}/search.js "query" -n 3 --content # Combined optionsbash
{baseDir}/search.js "query" # 基础搜索(返回5条结果)
{baseDir}/search.js "query" -n 10 # 更多结果(最多20条)
{baseDir}/search.js "query" --content # 包含以markdown格式呈现的页面内容
{baseDir}/search.js "query" --freshness pw # 返回过去一周的结果
{baseDir}/search.js "query" --freshness 2024-01-01to2024-06-30 # 自定义日期范围结果
{baseDir}/search.js "query" -n 3 --content # 组合选项使用Options
可选参数
- - Number of results (default: 5, max: 20)
-n <num> - - Fetch and include page content as markdown
--content - - Two-letter country code (default: US)
--country <code> - - Filter by time:
--freshness <period>- - Past day (24 hours)
pd - - Past week
pw - - Past month
pm - - Past year
py - - Custom date range
YYYY-MM-DDtoYYYY-MM-DD
- - 结果数量(默认:5,最大值:20)
-n <num> - - 获取并包含以markdown格式呈现的页面内容
--content - - 两位字母的国家代码(默认:US)
--country <code> - - 按时间过滤结果:
--freshness <period>- - 过去24小时
pd - - 过去一周
pw - - 过去一个月
pm - - 过去一年
py - - 自定义日期范围
YYYY-MM-DDtoYYYY-MM-DD
Extract Page Content
提取页面内容
bash
{baseDir}/content.js https://example.com/articleFetches a URL and extracts readable content as markdown.
bash
{baseDir}/content.js https://example.com/article获取指定URL并提取可读内容,以markdown格式输出。
Output Format
输出格式
--- Result 1 ---
Title: Page Title
Link: https://example.com/page
Age: 2 days ago
Snippet: Description from search results
Content: (if --content flag used)
Markdown content extracted from the page...
--- Result 2 ---
...--- Result 1 ---
Title: 页面标题
Link: https://example.com/page
Age: 2天前
Snippet: 搜索结果中的描述内容
Content: (当使用--content参数时显示)
从页面提取的Markdown内容...
--- Result 2 ---
...When to Use
使用场景
- Searching for documentation or API references
- Looking up facts or current information
- Fetching content from specific URLs
- Any task requiring web search without interactive browsing
- 搜索文档或API参考资料
- 查询事实信息或最新资讯
- 从特定URL获取内容
- 任何无需交互式浏览的网页搜索任务