searxng-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSearXNG Search Skill
SearXNG搜索技能
Search the web using a SearXNG instance via its API.
通过API调用SearXNG实例进行网页搜索。
Configuration
配置
The config file is read from (defaults to ).
$XDG_CONFIG_HOME/agents/searxng.json~/.config/agents/searxng.json配置文件读取路径为(默认路径为)。
$XDG_CONFIG_HOME/agents/searxng.json~/.config/agents/searxng.jsonConfig fields
配置字段
| Field | Type | Required | Description |
|---|---|---|---|
| | Yes | SearXNG instance URL (no trailing slash) |
| | No | Auth config object (see below) |
| | If auth | |
| | If bearer | Bearer token value (supports |
| | If basic | Basic auth username |
| | If basic | Basic auth password |
| | No | Key-value pairs of additional HTTP headers |
| | No | Default language code (e.g. |
| | No | Default categories (e.g. |
| | No | Default engines (e.g. |
| | No | Default safe search level: |
| | No | Default time range: |
| | No | Max results to display (default: |
| | No | Request timeout in seconds (default: |
| 字段 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| | 是 | SearXNG实例URL(末尾不要加斜杠) |
| | 否 | 认证配置对象(见下文) |
| | 配置了auth时必填 | 可选值 |
| | 认证类型为bearer时必填 | Bearer令牌值(支持读取 |
| | 认证类型为basic时必填 | Basic认证用户名 |
| | 认证类型为basic时必填 | Basic认证密码 |
| | 否 | 额外HTTP请求头的键值对 |
| | 否 | 默认语言代码(例如 |
| | 否 | 默认搜索分类(例如 |
| | 否 | 默认调用的搜索引擎(例如 |
| | 否 | 默认安全搜索等级: |
| | 否 | 默认搜索时间范围: |
| | 否 | 最大展示结果数(默认值: |
| | 否 | 请求超时时间,单位为秒(默认值: |
Example config (Bearer auth)
配置示例(Bearer认证)
json
{
"base_url": "https://searx.example.com",
"auth": {
"type": "bearer",
"token": "your-token-here"
},
"default_categories": ["general"],
"default_engines": ["google", "duckduckgo", "brave"],
"default_max_results": 10,
"headers": {
"X-Custom-Header": "value"
}
}json
{
"base_url": "https://searx.example.com",
"auth": {
"type": "bearer",
"token": "your-token-here"
},
"default_categories": ["general"],
"default_engines": ["google", "duckduckgo", "brave"],
"default_max_results": 10,
"headers": {
"X-Custom-Header": "value"
}
}Example config (Basic auth)
配置示例(Basic认证)
json
{
"base_url": "https://searx.example.com",
"auth": {
"type": "basic",
"user": "admin",
"pass": "password"
},
"default_safesearch": 1
}json
{
"base_url": "https://searx.example.com",
"auth": {
"type": "basic",
"user": "admin",
"pass": "password"
},
"default_safesearch": 1
}Usage
使用方法
Run the search script:
bash
python3 scripts/search.py [OPTIONS] <query>运行搜索脚本:
bash
python3 scripts/search.py [OPTIONS] <query>Options
可选参数
| Flag | Description |
|---|---|
| Comma-separated categories ( |
| Comma-separated engines ( |
| Language code ( |
| Page number (default: 1) |
| Time range: |
| Max results to show (overrides config default) |
| Safe search: |
| 标识 | 说明 |
|---|---|
| 逗号分隔的搜索分类(可选值: |
| 逗号分隔的搜索引擎(可选值: |
| 语言代码(可选值: |
| 页码(默认值:1) |
| 搜索时间范围: |
| 最大返回结果数(覆盖配置文件中的默认值) |
| 安全搜索等级: |
Examples
示例
bash
undefinedbash
undefinedBasic search
基础搜索
python3 scripts/search.py "SearXNG documentation"
python3 scripts/search.py "SearXNG documentation"
Search news from the last day
搜索最近一天的新闻
python3 scripts/search.py -c news -t day "latest tech news"
python3 scripts/search.py -c news -t day "latest tech news"
Search with specific engines, page 2
使用指定搜索引擎搜索,获取第2页结果
python3 scripts/search.py -e google,duckduckgo -p 2 "rust programming"
python3 scripts/search.py -e google,duckduckgo -p 2 "rust programming"
Search in Chinese with more results
中文搜索,返回更多结果
python3 scripts/search.py -l zh-CN -n 10 "开源搜索引擎"
undefinedpython3 scripts/search.py -l zh-CN -n 10 "开源搜索引擎"
undefinedBest Practices
最佳实践
- Technical topics (programming, software, science, IT, etc.): Always use English as both the query language and search language (), regardless of the user's input language. Translate the query to English if needed. English results are more comprehensive and up-to-date for technical content.
-l en - Chinese lifestyle topics (food, travel, shopping, local services, social trends, etc.): In addition to the default search, run a second search with using a Chinese query to capture China-specific results. Merge and deduplicate results before presenting to the user.
-e baidu,sogou -l zh-CN
- 技术类主题(编程、软件、科学、IT等):无论用户输入的是什么语言,查询语句和搜索语言都统一使用英文(),必要时将查询内容翻译成英文。技术类内容的英文搜索结果更全面、时效性更强。
-l en - 中文生活类主题(美食、旅行、购物、本地服务、社会热点等):除了默认搜索外,再使用中文查询词额外执行一次带参数的搜索,获取中文生态专属结果。合并结果并去重后再展示给用户。
-e baidu,sogou -l zh-CN
Workflow
工作流
- User asks to search for something
- Determine the topic type:
- Technical: translate query to English if needed, search with
-l en - Chinese lifestyle: run the default search first, then an additional search with
-e baidu,sogou -l zh-CN
- Technical: translate query to English if needed, search with
- Run with the query and any relevant filters
scripts/search.py - Present results to the user in a readable format
- If user wants more results, use for pagination or
-pfor more per page-n
- 用户提出搜索需求
- 判断主题类型:
- 技术类:必要时将查询词翻译成英文,使用参数搜索
-l en - 中文生活类:先执行默认搜索,再额外执行带参数的搜索
-e baidu,sogou -l zh-CN
- 技术类:必要时将查询词翻译成英文,使用
- 搭配查询词和相关筛选参数运行
scripts/search.py - 将结果以易读格式展示给用户
- 如果用户需要更多结果,使用参数翻页,或使用
-p参数提高单页返回结果数量-n