SearXNG Search
This skill enables web search using a custom SearXNG instance via its HTTP API.
Overview
SearXNG is a privacy-respecting metasearch engine that aggregates results from multiple search engines. This skill allows you to search using a custom SearXNG instance URL.
API Endpoints
- -
GET / or GET /search - Query parameters in URL - INLINECODE2 or
POST /search - Form data
Required Configuration
You need a SearXNG instance URL. The user can provide:
- 1. A public instance URL (e.g.,
https://searx.be) - A self-hosted instance URL
- An environment variable
SEARXNG_URL containing the instance URL
Parameters
| Parameter | Required | Description |
|---|
| INLINECODE6 | Yes | Search query string |
| INLINECODE7 |
No | Output format:
json,
csv,
rss (default: HTML) |
|
language | No | Language code (e.g.,
en,
zh,
de) |
|
pageno | No | Page number (default: 1) |
|
time_range | No | Time filter:
day,
month,
year |
|
categories | No | Comma-separated category list |
|
engines | No | Comma-separated engine list |
|
safesearch | No | Safe search level:
0,
1,
2 |
Categories and Engines
SearXNG organizes search into categories (tabs) with multiple engines per category.
Available Categories:
- -
general - General web search - INLINECODE27 - Image search
- INLINECODE28 - Video search
- INLINECODE29 - News articles
- INLINECODE30 - Maps and locations
- INLINECODE31 - Music and audio
- INLINECODE32 - IT/Technology resources
- INLINECODE33 - Scientific publications
- INLINECODE34 - Files and torrents
- INLINECODE35 - Social media content
Common Engines:
- - Web:
google, duckduckgo, bing, brave, startpage, INLINECODE41 - Images:
google images, bing images, unsplash, INLINECODE45 - Videos:
youtube, google videos, vimeo, INLINECODE49 - News:
google news, bing news, INLINECODE52 - IT:
github, stackoverflow, arch linux wiki, INLINECODE56 - Science:
google scholar, arxiv, INLINECODE59
Bang Syntax: Use ! prefix in queries to target specific engines:
- -
!go python - Search Google - INLINECODE62 - Search Wikipedia
- INLINECODE63 - Search GitHub
For detailed engine lists and features, see references/enginesand_categories.md.
Usage
Using the Python Script
CODEBLOCK0
Using HTTP Requests Directly
CODEBLOCK1
Bang Syntax in Query
CODEBLOCK2
JSON Response Format
CODEBLOCK3
Important Notes
- 1. Format Availability: JSON/CSV/RSS formats must be enabled in the instance's
settings.yml. Many public instances disable these formats. - Rate Limiting: Be respectful of the instance's resources. Add delays between requests.
- Self-Hosting: For reliable API access, consider self-hosting a SearXNG instance.
- Time Range: Not all engines support time range filtering. Check instance preferences.
- Engine Availability: Not all engines are enabled on all instances. Check the instance's preferences page.
Example Workflows
Basic Web Search
- 1. Ask user for SearXNG instance URL or use configured URL
- Construct search query
- Call API with INLINECODE65
- Parse and present results
Category-Specific Search
- 1. Choose category based on query type (news, images, science, etc.)
- Use
categories parameter or bang syntax - Filter results as needed
Multi-Page Search
- 1. Perform initial search
- If more results needed, increment
pageno parameter - Combine results from multiple pages
Filtered Search
- 1. Use
time_range=day for recent results - Use
safesearch=2 for strict filtering - Use
language parameter for locale-specific results - Use
categories or engines to narrow search scope
References
SearXNG搜索
该技能允许通过自定义SearXNG实例的HTTP API进行网络搜索。
概述
SearXNG是一个尊重隐私的元搜索引擎,聚合来自多个搜索引擎的结果。此技能允许您使用自定义的SearXNG实例URL进行搜索。
API端点
- - GET / 或 GET /search - URL中的查询参数
- POST / 或 POST /search - 表单数据
必要配置
您需要一个SearXNG实例URL。用户可以提供:
- 1. 公共实例URL(例如 https://searx.be)
- 自托管实例URL
- 包含实例URL的环境变量 SEARXNG_URL
参数
否 | 输出格式:json、csv、rss(默认:HTML) |
| language | 否 | 语言代码(例如 en、zh、de) |
| pageno | 否 | 页码(默认:1) |
| time_range | 否 | 时间筛选:day、month、year |
| categories | 否 | 逗号分隔的分类列表 |
| engines | 否 | 逗号分隔的引擎列表 |
| safesearch | 否 | 安全搜索级别:0、1、2 |
分类与引擎
SearXNG将搜索组织为分类(标签页),每个分类包含多个引擎。
可用分类:
- - general - 通用网络搜索
- images - 图片搜索
- videos - 视频搜索
- news - 新闻文章
- map - 地图和位置
- music - 音乐和音频
- it - IT/技术资源
- science - 科学出版物
- files - 文件和种子
- social_media - 社交媒体内容
常见引擎:
- - 网页:google、duckduckgo、bing、brave、startpage、wikipedia
- 图片:google images、bing images、unsplash、flickr
- 视频:youtube、google videos、vimeo、dailymotion
- 新闻:google news、bing news、reuters
- IT:github、stackoverflow、arch linux wiki、pypi
- 科学:google scholar、arxiv、pubmed
Bang语法: 在查询中使用 ! 前缀以定位特定引擎:
- - !go python - 搜索Google
- !wp artificial intelligence - 搜索Wikipedia
- !github machine learning - 搜索GitHub
有关详细的引擎列表和功能,请参阅 references/enginesand_categories.md。
使用方法
使用Python脚本
python
基本搜索
python scripts/searxng_search.py -u https://searx.example.org -q python tutorial
JSON输出
python scripts/searxng_search.py -u https://searx.example.org -q python tutorial --format json
带语言和时间范围
python scripts/searxng_search.py -u https://searx.example.org -q news --lang en --time-range day
使用环境变量作为URL
export SEARXNG_URL=https://searx.example.org
python scripts/searxng_search.py -q search query
搜索特定分类
python scripts/searxng_search.py -u https://searx.example.org -q AI --categories news
搜索特定引擎
python scripts/searxng_search.py -u https://searx.example.org -q python --engines google,stackoverflow
直接使用HTTP请求
python
import requests
url = https://searx.example.org/search
params = {
q: python tutorial,
format: json,
language: en,
categories: general,it, # 多个分类
engines: google,duckduckgo # 特定引擎
}
response = requests.get(url, params=params, timeout=30)
results = response.json()
查询中的Bang语法
python
使用bang语法定位特定引擎
params = {
q: !github machine learning framework, # 仅搜索GitHub
format: json
}
JSON响应格式
json
{
query: search query,
numberofresults: 1000000,
results: [
{
title: Result Title,
url: https://example.com,
content: Snippet text...,
engine: google,
score: 1.0
}
],
answers: [],
suggestions: [],
unresponsive_engines: []
}
重要说明
- 1. 格式可用性:JSON/CSV/RSS格式必须在实例的 settings.yml 中启用。许多公共实例禁用了这些格式。
- 速率限制:请尊重实例的资源。在请求之间添加延迟。
- 自托管:为了可靠的API访问,请考虑自托管SearXNG实例。
- 时间范围:并非所有引擎都支持时间范围筛选。请检查实例偏好设置。
- 引擎可用性:并非所有引擎都在所有实例上启用。请检查实例的偏好设置页面。
示例工作流程
基本网络搜索
- 1. 向用户询问SearXNG实例URL或使用已配置的URL
- 构建搜索查询
- 使用 format=json 调用API
- 解析并呈现结果
分类特定搜索
- 1. 根据查询类型选择分类(新闻、图片、科学等)
- 使用 categories 参数或bang语法
- 根据需要筛选结果
多页搜索
- 1. 执行初始搜索
- 如果需要更多结果,增加 pageno 参数
- 合并多页结果
筛选搜索
- 1. 使用 time_range=day 获取最新结果
- 使用 safesearch=2 进行严格筛选
- 使用 language 参数获取特定区域的结果
- 使用 categories 或 engines 缩小搜索范围
参考