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 @@ English | [中文](./README.zh.md)
## Features
- 🔍 **Multi-engine Aggregation** - Use multiple search engines at the same time (Google, Brave, DuckDuckGo, Bing)
- 🔍 **Multi-engine Aggregation** - Use DuckDuckGo and Bing at the same time
- 🤖 **AI Enhanced (MCP)** - Native support for Model Context Protocol, one-click search tool integration for **OpenClaw** / **Claude Code** / **Codex**
-**Parallel Search** - All search engines are requested concurrently for faster results
- 🛡️ **Fault Tolerance** - Failure of a single engine does not affect others; unresponsive engines are automatically marked
@@ -132,7 +132,7 @@ Search using query parameters:
curl "https://$YOUR-DOMAIN/search?q=cloudflare"
# Specify search engines
curl "https://$YOUR-DOMAIN/search?q=cloudflare&engines=google,brave"
curl "https://$YOUR-DOMAIN/search?q=cloudflare&engines=duckduckgo,bing"
# Use token authentication (if TOKEN env var is configured)
curl "https://$YOUR-DOMAIN/search?q=cloudflare&token=$YOUR-TOKEN"
@@ -145,7 +145,7 @@ Submit search by POST form:
```bash
curl -X POST "https://$YOUR-DOMAIN/search" \
-d "q=cloudflare" \
-d "engines=google,brave"
-d "engines=duckduckgo,bing"
-d "token=$YOUR-TOKEN" # if TOKEN env var is configured
```
@@ -160,13 +160,11 @@ Used to execute search queries and return aggregated results.
| Parameter | Type | Required | Description | Example |
| ------------- | -------- | -------- | ---------------------------------------------------------- | ---------------- |
| `q` / `query` | `string` | yes | Search keyword | `cloudflare` |
| `engines` | `string` | no | Specify search engines, separated by commas | `google,brave` |
| `engines` | `string` | no | Specify search engines, separated by commas | `duckduckgo,bing` |
| `token` | `string` | no/yes | Access token (required when `TOKEN` env var is configured) | `$YOUR-TOKEN` |
**Supported Search Engines**:
- `google` - Google Search (requires API Key configuration)
- `brave` - Brave Search
- `duckduckgo` - DuckDuckGo Search
- `bing` - Bing Search
@@ -178,6 +176,8 @@ Used to execute search queries and return aggregated results.
number_of_results: number; // Total number of results
enabled_engines: string[]; // Enabled search engine list
unresponsive_engines: string[]; // Unresponsive search engine list
empty_engines: string[]; // Engines that responded with no results
engine_errors: Record<string, string>; // Error message by engine
results: Array<{
title: string; // Result title
description: string; // Result description
@@ -191,12 +191,12 @@ Used to execute search queries and return aggregated results.
```bash
# GET request
curl "https://$YOUR-DOMAIN/search?q=cloudflare&engines=google,brave"
curl "https://$YOUR-DOMAIN/search?q=cloudflare&engines=duckduckgo,bing"
# POST request
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"
```
#### Response Example
@@ -205,20 +205,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"
}
]
}
@@ -230,9 +232,7 @@ curl -X POST "https://$YOUR-DOMAIN/search" \
| Engine | Description | Configuration Required | Enabled by Default |
| -------------- | ---------------------------- | ------------------------------- | ------------------ |
| **Google** | Google Custom Search API | Requires `GOOGLE_API_KEY` and `GOOGLE_CX` | yes |
| **Brave** | Brave Search API | - | yes |
| **DuckDuckGo** | DuckDuckGo Instant Answer API | - | yes |
| **DuckDuckGo** | DuckDuckGo HTML search | - | yes |
| **Bing** | Bing Search | - | no (unstable results) |
### Basic Working Approach
@@ -249,13 +249,10 @@ curl -X POST "https://$YOUR-DOMAIN/search" \
| Variable Name | Type | Default | Description |
| ------------------ | -------- | -------- | --------------------------------------------------- |
| `DEFAULT_TIMEOUT` | `string` | `"3000"` | Timeout per search engine request (milliseconds) |
| `GOOGLE_API_KEY` | `string` | `null` | https://console.cloud.google.com/apis/credentials |
| `GOOGLE_CX` | `string` | `null` | https://programmablesearchengine.google.com/ |
| `TOKEN` | `string` | `null` | Access token. Enables auth when configured to prevent abuse |
**Notes**:
- Google Custom Search API free tier is limited to 100 requests per day
- After `TOKEN` is configured, all requests must provide a valid token
### Configuration Methods
@@ -266,8 +263,6 @@ Edit the `[vars]` section in `wrangler.toml`:
```toml
[vars]
GOOGLE_API_KEY = "your-google-api-key"
GOOGLE_CX = "your-google-custom-search-cx"
DEFAULT_TIMEOUT = "3000"
TOKEN = "your-secret-token-here"
```
@@ -286,7 +281,7 @@ Build your own aggregated search API and combine results from multiple search en
```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(`Found ${data.number_of_results} results`);
@@ -311,7 +306,7 @@ async function search(query) {
Collect results from multiple search engines for comparative analysis:
```javascript
const engines = ["google", "brave", "duckduckgo"];
const engines = ["duckduckgo", "bing"];
const results = await fetch(
`https://$YOUR-DOMAIN/search?q=AI&engines=${engines.join(",")}`,
);
@@ -339,7 +334,6 @@ With MCP (Model Context Protocol), AI assistants can directly call your search s
- In Worker settings, click **Triggers** > **Add Custom Domain** to add a custom domain
2. **Search Engine Limits**
- Google API free tier is limited to 100 requests per day
- Other search engines generally do not have strict limits, but please use responsibly
- Frequent requests may cause temporary rate limiting
@@ -380,7 +374,6 @@ A: Possible reasons:
- Search engine API is temporarily unavailable or timed out
- No relevant results for the search keyword
- Search engine has rate-limited access
- Google requires API Key configuration before use
You can check the `unresponsive_engines` field in the response to see which engines did not respond.
@@ -427,7 +420,6 @@ Issues and Pull Requests are welcome!
- [Project GitHub](https://github.com/Yrobot/cloudflare-search)
- [Cloudflare Workers Docs](https://developers.cloudflare.com/workers/)
- [Google Custom Search API](https://developers.google.com/custom-search/v1/overview)
## Support the Project