一个 r/n8n 线程提到 OP 正在使用“Google 自定义搜索加手动抓取”并且想要一个 API。本教程走替换路径。
前置条件
- Python 3.10+
- Scavio API 密钥
操作指南
步骤 1: 识别 Google 自定义搜索调用
通常带有 CSE 密钥 + cx ID。
Python
# Before:
# r = requests.get('https://www.googleapis.com/customsearch/v1', params={'key': KEY, 'cx': CX, 'q': q})步骤 2: 更换为Scavio
无需客户体验; Scavio 搜索开放网络。
Python
# After:
r = requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': SCAVIO_API_KEY},
json={'query': q}).json()步骤 3: 地图响应
items[] 变为 Organic_results[]。
Python
# Google CSE: r['items'][i]['link']
# Scavio: r['organic_results'][i]['link']步骤 4: 添加内容提取端点
取代了 OP 流程的“手动抓取”一半。
Python
def fetch(url):
return requests.post('https://api.scavio.dev/api/v1/extract',
headers={'x-api-key': SCAVIO_API_KEY}, json={'url': url, 'format': 'markdown'}).json().get('markdown', '')步骤 5: 比较配额
Google CSE 免费上限为 100 个/天,5 美元/1K 以上。 Scavio 免费为 250 个积分/月 + 7K 每月 30 美元。
Text
// Daily research agent making 50 queries: Google CSE = $7.50/mo above quota; Scavio = $0 above the 250 free tier or $30/mo flat.Python 示例
Python
# Migration takes ~20 minutes for a typical agent.JavaScript 示例
JavaScript
// Same in TS.预期输出
JSON
Same query intent, structured JSON, plus extract endpoint that replaces 'manual scraping' under the same key. No more two-vendor split.