chore: sync local changes to Gitea

This commit is contained in:
shumengya
2026-06-24 22:10:22 +08:00
parent df308e3ae6
commit 9e24d85cd0
13 changed files with 81 additions and 331 deletions

View File

@@ -10,7 +10,7 @@
## 特性
- 🔍 **多引擎聚合** - 同时使用多个搜索引擎Google、Brave、DuckDuckGoBing
- 🔍 **多引擎聚合** - 同时使用 DuckDuckGoBing 搜索引擎
- 🤖 **AI 增强 (MCP)** - 原生支持 Model Context Protocol一键为 **OpenClaw** / **Claude Code** / **Codex** 添加搜索工具
-**并行搜索** - 所有搜索引擎同时请求,快速返回结果
- 🛡️ **容错机制** - 单个引擎失败不影响其他引擎,自动标记无响应引擎
@@ -134,7 +134,7 @@ https://$YOUR-DOMAIN/
curl "https://$YOUR-DOMAIN/search?q=cloudflare"
# 指定搜索引擎
curl "https://$YOUR-DOMAIN/search?q=cloudflare&engines=google,brave"
curl "https://$YOUR-DOMAIN/search?q=cloudflare&engines=duckduckgo,bing"
# 使用 token 鉴权(如果配置了 TOKEN 环境变量)
curl "https://$YOUR-DOMAIN/search?q=cloudflare&token=$YOUR-TOKEN"
@@ -147,7 +147,7 @@ curl "https://$YOUR-DOMAIN/search?q=cloudflare&token=$YOUR-TOKEN"
```bash
curl -X POST "https://$YOUR-DOMAIN/search" \
-d "q=cloudflare" \
-d "engines=google,brave"
-d "engines=duckduckgo,bing"
-d "token=$YOUR-TOKEN" # 如果配置了 TOKEN 环境变量
```
@@ -162,13 +162,11 @@ curl -X POST "https://$YOUR-DOMAIN/search" \
| 参数 | 类型 | 必填 | 说明 | 示例 |
| ------------- | -------- | ------ | ----------------------------------------- | -------------- |
| `q` / `query` | `string` | yes | 搜索关键词 | `cloudflare` |
| `engines` | `string` | no | 指定搜索引擎,多个用逗号分隔 | `google,brave` |
| `token` | `string` | no/yse | 访问令牌(当配置了 TOKEN 环境变量时必填) | `$YOUR-TOKEN` |
| `engines` | `string` | no | 指定搜索引擎,多个用逗号分隔 | `duckduckgo,bing` |
| `token` | `string` | no/yes | 访问令牌(当配置了 TOKEN 环境变量时必填) | `$YOUR-TOKEN` |
**支持的搜索引擎**
- `google` - Google 搜索(需要配置 API Key
- `brave` - Brave 搜索
- `duckduckgo` - DuckDuckGo 搜索
- `bing` - Bing 搜索
@@ -180,6 +178,8 @@ curl -X POST "https://$YOUR-DOMAIN/search" \
number_of_results: number; // 结果总数
enabled_engines: string[]; // 启用的搜索引擎列表
unresponsive_engines: string[]; // 无响应的搜索引擎列表
empty_engines: string[]; // 响应成功但无结果的搜索引擎列表
engine_errors: Record<string, string>; // 各搜索引擎错误信息
results: Array<{
title: string; // 结果标题
description: string; // 结果描述
@@ -193,12 +193,12 @@ curl -X POST "https://$YOUR-DOMAIN/search" \
```bash
# GET 请求
curl "https://$YOUR-DOMAIN/search?q=cloudflare&engines=google,brave"
curl "https://$YOUR-DOMAIN/search?q=cloudflare&engines=duckduckgo,bing"
# POST 请求
curl -X POST "https://$YOUR-DOMAIN/search" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "q=cloudflare&engines=google,brave"
-d "q=cloudflare&engines=duckduckgo,bing"
```
#### 响应示例
@@ -207,20 +207,22 @@ curl -X POST "https://$YOUR-DOMAIN/search" \
{
"query": "cloudflare",
"number_of_results": 15,
"enabled_engines": ["google", "brave", "duckduckgo"],
"enabled_engines": ["duckduckgo", "bing"],
"unresponsive_engines": [],
"empty_engines": [],
"engine_errors": {},
"results": [
{
"title": "Cloudflare - The Web Performance & Security Company",
"description": "Cloudflare is on a mission to help build a better Internet...",
"url": "https://www.cloudflare.com/",
"engine": "google"
"engine": "duckduckgo"
},
{
"title": "Cloudflare Workers",
"description": "Deploy serverless code instantly across the globe...",
"url": "https://workers.cloudflare.com/",
"engine": "brave"
"engine": "bing"
}
]
}
@@ -232,9 +234,7 @@ curl -X POST "https://$YOUR-DOMAIN/search" \
| 引擎 | 说明 | 是否需要配置 | 默认启用 |
| -------------- | ------------------------ | ----------------------------- | --------------- |
| **Google** | Google Custom Search API | 需要 GOOGLE_API_KEY GOOGLE_CX | yes |
| **Brave** | Brave Search API | - | yes |
| **DuckDuckGo** | DuckDuckGo 即时答案 API | - | yes |
| **DuckDuckGo** | DuckDuckGo HTML 搜索 | - | yes |
| **Bing** | Bing 搜索 | - | no (结果不稳定) |
### 基本工作方案
@@ -251,13 +251,10 @@ curl -X POST "https://$YOUR-DOMAIN/search" \
| 变量名 | 类型 | 默认值 | 说明 |
| ----------------- | -------- | -------- | ------------------------------------------------- |
| `DEFAULT_TIMEOUT` | `string` | `"3000"` | 单个搜索引擎的超时时间(毫秒) |
| `GOOGLE_API_KEY` | `string` | `null` | https://console.cloud.google.com/apis/credentials |
| `GOOGLE_CX` | `string` | `null` | https://programmablesearchengine.google.com/ |
| `TOKEN` | `string` | `null` | 访问令牌,配置后启用鉴权,保护服务不被滥用 |
**注意**
- Google Custom Search API 免费版每天限制 100 次请求
- `TOKEN` 配置后,所有请求都需要提供有效的 token
### 配置方式
@@ -268,8 +265,6 @@ curl -X POST "https://$YOUR-DOMAIN/search" \
```toml
[vars]
GOOGLE_API_KEY = "your-google-api-key"
GOOGLE_CX = "your-google-custom-search-cx"
DEFAULT_TIMEOUT = "3000"
TOKEN = "your-secret-token-here"
```
@@ -288,7 +283,7 @@ TOKEN = "your-secret-token-here"
```javascript
const response = await fetch(
"https://$YOUR-DOMAIN/search?q=javascript&engines=google,brave",
"https://$YOUR-DOMAIN/search?q=javascript&engines=duckduckgo,bing",
);
const data = await response.json();
console.log(`找到 ${data.number_of_results} 个结果`);
@@ -313,7 +308,7 @@ async function search(query) {
收集多个搜索引擎的结果进行对比分析:
```javascript
const engines = ["google", "brave", "duckduckgo"];
const engines = ["duckduckgo", "bing"];
const results = await fetch(
`https://$YOUR-DOMAIN/search?q=AI&engines=${engines.join(",")}`,
);
@@ -341,7 +336,6 @@ const byEngine = data.results.reduce((acc, result) => {
- 在 Worker 设置中点击 **Triggers** > **Add Custom Domain** 添加自定义域名
2. **搜索引擎限制**
- Google API 免费版每天限制 100 次请求
- 其他搜索引擎一般没有严格限制,但请合理使用
- 频繁请求可能导致被临时限制访问
@@ -382,7 +376,6 @@ A: 可能原因:
- 搜索引擎 API 临时不可用或响应超时
- 搜索关键词没有相关结果
- 搜索引擎限制了访问频率
- Google 需要配置 API Key 才能使用
可以查看返回的 `unresponsive_engines` 字段了解哪些引擎没有响应。
@@ -429,7 +422,6 @@ A: 建议配置 `TOKEN` 环境变量启用鉴权:
- [项目 GitHub](https://github.com/Yrobot/cloudflare-search)
- [Cloudflare Workers 文档](https://developers.cloudflare.com/workers/)
- [Google Custom Search API](https://developers.google.com/custom-search/v1/overview)
## 支持一下