Smart web search with automatic fallback when WebSearch fails
Intelligent web search with automatic fallback to HTML scraping when the primary API fails or hits rate limits. Use this when you need guaranteed search results for current information, especially if standard web search tools frequently fail.
/plugin marketplace add bejranonda/LLM-Autonomous-Agent-Plugin-for-Claude/plugin install bejranonda-autonomous-agent@bejranonda/LLM-Autonomous-Agent-Plugin-for-Clauderesearch//search-smart <query>Intelligent web search that automatically uses the Web Search Fallback system when the WebSearch API fails or hits limits.
# Basic search
/search-smart AI trends 2025
# Search with specific result count
/search-smart "quantum computing breakthroughs" -n 10
# Search with no cache (fresh results)
/search-smart "latest news today" --no-cache
# Python implementation using the plugin
import sys
import os
# Add plugin path
plugin_path = os.path.expanduser("~/.config/claude/plugins/autonomous-agent")
if os.path.exists(plugin_path):
sys.path.insert(0, os.path.join(plugin_path, "lib"))
from web_search_fallback import WebSearchFallback
def search_smart(query, num_results=10):
# Try WebSearch first (if available)
try:
from web_search import search as web_search
result = web_search(query)
if result and len(result) > 0:
return result
except:
pass
# Use fallback
searcher = WebSearchFallback()
return searcher.search(query, num_results=num_results)
#!/bin/bash
function search_smart() {
local query="$1"
local num_results="${2:-10}"
# Try to find the plugin
if [ -f "$HOME/.config/claude/plugins/autonomous-agent/lib/web_search_fallback.py" ]; then
python3 "$HOME/.config/claude/plugins/autonomous-agent/lib/web_search_fallback.py" \
"$query" -n "$num_results"
else
# Direct fallback
curl -s -A "Mozilla/5.0" \
"https://html.duckduckgo.com/html/?q=$(echo "$query" | sed 's/ /+/g')" \
| grep -o '<a[^>]*class="result__a"[^>]*>[^<]*</a>' \
| sed 's/<[^>]*>//g' \
| head -n "$num_results"
fi
}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔍 SMART WEB SEARCH RESULTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Query: "AI trends 2025"
Method: Fallback (WebSearch unavailable)
Results: 5
1. The 10 Biggest AI Trends Of 2025
https://forbes.com/...
2. AI Trends to Watch in 2025 & Beyond
https://analyticsinsight.net/...
3. What's Next for AI in 2025
https://technologyreview.com/...
[Cache: Hit] [Time: 0.2s]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
This command can be used by:
rm -rf .claude-patterns/search-cache/
python3 lib/web_search_fallback.py "test query" -v
Use /search-smart when: