Google 网页搜索技能 - 使用 Google Custom Search API 进行全球网络搜索
PropertyValueNamegoogle-web-searchVersion1.0.0AuthorPocketAI for LeoLicenseMITCategorySearchRequired Env VarsGOOGLE_API_KEY, GOOGLE_CX
This skill requires the following environment variables:
VariableDescriptionRequiredHow to GetGOOGLE_API_KEYGoogle Custom Search API key✅ Yeshttps://console.cloud.google.com/GOOGLE_CXCustom Search Engine ID✅ Yeshttps://programmablesearchengine.google.com/
Configuration:
bash
export GOOGLE_API_KEY="your_google_api_key"
export GOOGLE_CX="your_search_engine_id"
bash
cd ~/.openclaw/workspace/skills
# Already installed at: google-web-search/
Option 1: Using .env file (Recommended)
bash
# Copy the example .env file
cp .env.example .env
# Edit .env and add your API keys
nano .env # or use your favorite editor
Option 2: Using environment variables
bash
export GOOGLE_API_KEY="your_google_api_key"
export GOOGLE_CX="your_search_engine_id"
python
from src.google_search import google_search
# Search with default 10 results
result = google_search("AI trends 2026")
print(result)
# Search with custom result count
result = google_search("electric vehicles", count=5)
print(result)
bash
# Search with default 10 results
python3 src/google_search.py "AI trends 2026"
# Search with custom result count
python3 src/google_search.py "electric vehicles" 5
python
from src.google_search import GoogleSearch, google_search
# Method 1: Simple search
result = google_search("OpenClaw AI", count=10)
print(result)
# Method 2: Using client
searcher = GoogleSearch(
api_key="your_api_key",
cx="your_cx_id"
)
results = searcher.search("OpenClaw", count=10)
for result in results:
print(f"Title: {result['title']}")
print(f"URL: {result['url']}")
print(f"Snippet: {result['snippet']}")
print(f"Source: {result['display_link']}\n")
VariableDescriptionRequiredGOOGLE_API_KEYGoogle Custom Search API key✅ YesGOOGLE_CXCustom Search Engine ID✅ Yes
text
google-web-search/
├── src/
│ └── google_search.py # Main search client
├── SKILL.md # This file
└── README.md # Documentation
python
result = google_search("latest tech news 2026")
python
result = google_search("AI healthcare applications research")
python
result = google_search("smartphone reviews 2026")
python
result = google_search("machine learning papers site:arxiv.org")
json
{
"title": "Page Title",
"url": "https://example.com/page",
"snippet": "Page description snippet",
"display_link": "example.com"
}
text
🔍 Google Search Results for: AI trends 2026
Found 10 results:
1. **Top AI Trends to Watch in 2026**
Source: forbes.com
URL: https://forbes.com/ai-trends-2026
Artificial intelligence continues to evolve rapidly...
2. **The Future of AI in 2026**
Source: mit.edu
URL: https://mit.edu/ai-future-2026
MIT researchers predict major breakthroughs...
MIT License - See LICENSE file for details.
Happy Searching! 🔍
Last Updated: 2026-03-17
Version: 1.0.0
Author: PocketAI for Leo