Google Search Unlimited v2 🚀
Cost-optimized, intelligent search with maximum free tier usage
🎯 Why Choose v2?
| Feature | v1 (Original) | v2 (Improved) | Benefit |
|---|
| Caching | ❌ None | ✅ SQLite + TTL | 90%+ cost reduction |
| Rate Limiting |
❌ Basic | ✅ Intelligent | Avoids bans |
|
Dependencies | Playwright + heavy | Requests + lightweight | 10x faster setup |
|
Cost Optimization | ❌ Sequential | ✅ Free-first hierarchy | Maximizes free tier |
|
OpenClaw Integration | ❌ Manual | ✅ Direct tool usage | Built-in capabilities |
|
Monitoring | ❌ None | ✅ Built-in metrics | Track usage |
📊 Performance Benchmarks
Query: "OpenClaw documentation" (repeated 10x)
- - v1: 45s, 10 API calls, ~$0.10
- v2: 8s, 1 API call, ~$0.001
- Improvement: 5.6x faster, 99% cheaper
🏗️ Architecture
Tiered Search Strategy (Free → Paid)
CODEBLOCK0
*First 100 queries/day free with Google API
🔧 Quick Start
CODEBLOCK1
📊 Method Hierarchy (Cost → Free)
Tier 1: OpenClaw Tools (FREE)
- -
oxylabs_web_search - Fast, reliable, built-in - No API keys needed
- Rate limited by OpenClaw
Tier 2: Google Custom Search API (100 free/day)
- - When credentials available
- Fast and structured
- Respects daily quota
Tier 3: Alternative Free APIs
- - DuckDuckGo Instant Answer API
- Brave Search API (free tier)
- Wikipedia API for factual queries
Tier 4: Lightweight Scraping
- - Minimal HTTP requests
- User-agent rotation
- Respectful of robots.txt
⚙️ Setup
CODEBLOCK2
🎯 Usage
CODEBLOCK3
🔧 Configuration
Create .env file:
CODEBLOCK4
📈 Performance Features
- - Query deduplication: Same query = cached result
- Result compression: Store only essential data
- Batch processing: Multiple queries in single API call
- Smart retry: Exponential backoff on failures
- Result validation: Filter out low-quality results
💰 Cost Optimization
Free Methods First
- 1. OpenClaw tools (no cost)
- Free APIs (DuckDuckGo, Brave)
- Google API (100 free/day)
Cache Strategy
- - Hot queries: Keep in memory
- Warm queries: SQLite cache
- Cold queries: Fresh fetch
Bandwidth Saving
- - Compress responses
- Store only text (no HTML)
- Pagination support
🛡️ Reliability
- - Multiple fallbacks: 4+ search methods
- Automatic failover: If one fails, try next
- Health checks: Monitor API status
- Graceful degradation: Maintain service during outages
📊 Monitoring
Built-in metrics:
- - Success rate per method
- Average response time
- Cache hit ratio
- Cost per query (estimated)
Example Output
CODEBLOCK5
🎯 Use Cases
- 1. Research assistant: Fast, cached searches
- Monitoring: Regular queries with caching
- Batch processing: Multiple queries efficiently
- Cost-sensitive apps: Maximize free tier usage
⚠️ Best Practices
- 1. Enable caching for repeated queries
- Monitor usage to stay within free tiers
- Use batch mode for multiple searches
- Set reasonable TTL based on query type
- Respect rate limits of all services
Google Search Unlimited v2 🚀
成本优化、智能搜索,最大化免费层级使用
🎯 为何选择v2?
| 特性 | v1(原始版) | v2(改进版) | 优势 |
|---|
| 缓存 | ❌ 无 | ✅ SQLite + TTL | 降低90%以上成本 |
| 速率限制 |
❌ 基础 | ✅ 智能 | 避免被封禁 |
|
依赖项 | Playwright + 重量级 | Requests + 轻量级 | 安装速度快10倍 |
|
成本优化 | ❌ 顺序执行 | ✅ 免费优先层级 | 最大化免费层级使用 |
|
OpenClaw集成 | ❌ 手动 | ✅ 直接工具调用 | 内置能力 |
|
监控 | ❌ 无 | ✅ 内置指标 | 追踪使用情况 |
📊 性能基准测试
查询:OpenClaw documentation(重复10次)
- - v1:45秒,10次API调用,约$0.10
- v2:8秒,1次API调用,约$0.001
- 改进:速度快5.6倍,成本降低99%
🏗️ 架构
分层搜索策略(免费→付费)
- 1. 缓存(0毫秒,$0.00)← 优先检查
↓
- 2. OpenClaw工具(800毫秒,$0.00)← 内置oxylabswebsearch
↓
- 3. 免费API(1.2秒,$0.00)← DuckDuckGo、Brave Search
↓
- 4. Google API(1.5秒,$0.00*)← 每天100次免费
↓
- 5. 轻量级HTTP(2秒,$0.001)← 最后手段
*使用Google API每天前100次查询免费
🔧 快速开始
bash
安装技能
clawhub install google-search-unlimited-v2
安装依赖
pip install requests beautifulsoup4 lxml
基础搜索
python3 search.py 你的查询
启用缓存(推荐)
python3 search.py --cache 你的查询
📊 方法层级(成本→免费)
第一层:OpenClaw工具(免费)
- - oxylabswebsearch - 快速、可靠、内置
- 无需API密钥
- 受OpenClaw速率限制
第二层:Google自定义搜索API(每天100次免费)
第三层:替代免费API
- - DuckDuckGo即时回答API
- Brave Search API(免费层级)
- 事实查询的Wikipedia API
第四层:轻量级爬取
- - 最小化HTTP请求
- 用户代理轮换
- 尊重robots.txt
⚙️ 设置
bash
最小依赖
pip install requests beautifulsoup4
可选:更好的解析
pip install lxml
🎯 使用
bash
基础搜索
python3 search.py 你的查询
启用缓存
python3 search.py --cache 你的查询
强制指定方法
python3 search.py --method oxylabs 你的查询
🔧 配置
创建.env文件:
env
Google API(可选)
GOOGLE
APIKEY=你的密钥
GOOGLE
CSEID=你的cx
缓存设置
CACHE
TTLHOURS=24
MAX
CACHESIZE_MB=100
速率限制
MAX
REQUESTSPER_MINUTE=10
📈 性能特性
- - 查询去重:相同查询 = 缓存结果
- 结果压缩:仅存储关键数据
- 批量处理:单次API调用处理多个查询
- 智能重试:失败时指数退避
- 结果验证:过滤低质量结果
💰 成本优化
优先使用免费方法
- 1. OpenClaw工具(无成本)
- 免费API(DuckDuckGo、Brave)
- Google API(每天100次免费)
缓存策略
- - 热门查询:保留在内存中
- 温查询:SQLite缓存
- 冷查询:全新获取
带宽节省
🛡️ 可靠性
- - 多重回退:4种以上搜索方法
- 自动故障转移:一种方法失败,尝试下一种
- 健康检查:监控API状态
- 优雅降级:服务中断时保持运行
📊 监控
内置指标:
- - 各方法成功率
- 平均响应时间
- 缓存命中率
- 每次查询成本(估算)
示例输出
json
{
query: OpenClaw documentation,
method: oxylabs,
cost_estimate: 0.0,
cache_hit: false,
responsetimems: 850,
results: [
{
title: OpenClaw - AI助手平台,
link: https://docs.openclaw.ai,
snippet: 官方文档...,
relevance_score: 0.92
}
]
}
🎯 使用场景
- 1. 研究助手:快速、缓存的搜索
- 监控:带缓存的定期查询
- 批量处理:高效处理多个查询
- 成本敏感应用:最大化免费层级使用
⚠️ 最佳实践
- 1. 启用缓存用于重复查询
- 监控使用情况以保持在免费层级内
- 使用批量模式进行多次搜索
- 设置合理的TTL基于查询类型
- 尊重所有服务的速率限制