SearXNG Web Search
Search the web using a self-hosted SearXNG instance. This skill provides access to web search results through the SearXNG JSON API, with built-in rate limiting, error handling, and result formatting.
When to Use
Use this skill when you need to:
- - Find current information or recent news
- Research topics beyond your knowledge cutoff
- Look up documentation or technical references
- Verify facts or check current status
- Find URLs or resources on specific topics
- Search for code examples or solutions
Configuration
Set the SEARXNG_URL environment variable to your SearXNG instance:
CODEBLOCK0
Or use the default (http://localhost:8888) if not set.
Usage
Execute the search script with your query:
CODEBLOCK1
Advanced Options
Pass additional parameters as JSON:
CODEBLOCK2
Available options:
- -
category - Filter by category: general, news, images, videos, it, science - INLINECODE2 - Time filter: day, week, month, year
- INLINECODE3 - Language code (default: en)
- INLINECODE4 - Number of results to return (default: 5)
Output Format
The script returns formatted search results as text:
CODEBLOCK3
Error Handling
The script handles common errors gracefully:
- - Network timeouts (30s timeout)
- SearXNG unavailable (clear error message)
- Invalid queries (error details)
- Rate limiting (429 responses)
- Empty results (informative message)
Rate Limiting
The script implements basic rate limiting:
- - Minimum 1 second between requests
- Uses filesystem-based state (
.searxng-last-request) - Prevents accidental spam
Examples
Basic Search
CODEBLOCK4
News Search
CODEBLOCK5
Technical Search
CODEBLOCK6
Recent Results Only
CODEBLOCK7
Troubleshooting
"SEARXNG_URL not set"
- - Set the environment variable: INLINECODE6
Connection timeout
- - Check that SearXNG is running: INLINECODE7
- Verify firewall settings
- Check service status: INLINECODE8
Empty results
- - Try a broader query
- Remove filters and try again
- Check SearXNG logs: INLINECODE9
Rate limit errors
- - Wait a few seconds between searches
- The script enforces minimum 1s delay automatically
Implementation Notes
The search script (scripts/search.clj) uses:
- -
babashka.http-client for HTTP requests - Clojure's
cheshire.core for JSON parsing - Filesystem-based rate limiting
- 30-second timeout with proper error messages
- Result scoring and sorting for best results first
For detailed API documentation, see references/api-guide.md.
SearXNG 网络搜索
使用自托管的 SearXNG 实例搜索网络。该技能通过 SearXNG JSON API 提供网络搜索结果访问,内置速率限制、错误处理和结果格式化功能。
使用场景
在以下情况下使用此技能:
- - 查找最新信息或近期新闻
- 研究超出知识截止日期的话题
- 查阅文档或技术参考资料
- 验证事实或检查当前状态
- 查找特定主题的网址或资源
- 搜索代码示例或解决方案
配置
将 SEARXNG_URL 环境变量设置为你的 SearXNG 实例:
bash
export SEARXNG_URL=http://localhost:8888
若未设置,则使用默认值 (http://localhost:8888)。
使用方法
使用查询内容执行搜索脚本:
bash
bb scripts/search.clj 你的搜索查询
高级选项
以 JSON 格式传递额外参数:
bash
bb scripts/search.clj 你的查询 {category: news, timerange: day, numresults: 10}
可用选项:
- - category - 按类别筛选:general、news、images、videos、it、science
- timerange - 时间筛选:day、week、month、year
- language - 语言代码(默认:en)
- numresults - 返回结果数量(默认:5)
输出格式
脚本以文本形式返回格式化搜索结果:
你的查询的搜索结果
共找到 42 条结果
- 1. 结果标题 [评分:1.85]
网址:https://example.com/page
页面描述摘要...
搜索引擎:google, bing
- 2. 另一个结果 [评分:1.62]
...
错误处理
脚本优雅地处理常见错误:
- - 网络超时(30秒超时)
- SearXNG 不可用(清晰的错误信息)
- 无效查询(错误详情)
- 速率限制(429响应)
- 空结果(提示信息)
速率限制
脚本实现基本速率限制:
- - 请求间隔至少1秒
- 使用基于文件系统的状态(.searxng-last-request)
- 防止意外滥用
示例
基本搜索
bash
bb scripts/search.clj NixOS 配置
新闻搜索
bash
bb scripts/search.clj AI 发展 {category: news, time_range: week}
技术搜索
bash
bb scripts/search.clj babashka http 客户端 {category: it, num_results: 3}
仅最新结果
bash
bb scripts/search.clj 产品发布 {time_range: day}
故障排除
SEARXNG_URL 未设置
- - 设置环境变量:export SEARXNG_URL=http://localhost:8888
连接超时
- - 检查 SearXNG 是否运行:curl $SEARXNG_URL/search?q=test&format=json
- 验证防火墙设置
- 检查服务状态:systemctl status searx
空结果
- - 尝试更宽泛的查询
- 移除筛选条件后重试
- 检查 SearXNG 日志:journalctl -u searx -n 50
速率限制错误
- - 在搜索之间等待几秒
- 脚本自动强制执行至少1秒延迟
实现说明
搜索脚本(scripts/search.clj)使用:
- - babashka.http-client 进行 HTTP 请求
- Clojure 的 cheshire.core 进行 JSON 解析
- 基于文件系统的速率限制
- 30秒超时并带有适当的错误信息
- 结果评分和排序,优先显示最佳结果
详细 API 文档请参见 references/api-guide.md。