Bright Data 的 SERP API 需要每月 499 美元的最低承诺、区域配置、代理管理和 IP 白名单,然后才能运行单个查询。对于需要结构化搜索结果而无需企业代理基础设施的团队,像 Scavio 这样的轻量级 API 通过单个 POST 端点以 0.005 美元/积分的价格提供相同的有机结果、特色片段和 PAA 数据,并且没有最低支出。本教程将并排介绍这两种设置,以便您可以在 15 分钟内评估权衡。
前置条件
- 已安装 Python 3.8+
- 安装请求库(pip install requests)
- Bright Data 帐户(用于 Bright Data 路径)
- 来自 scavio.dev 的 Scavio API 密钥(用于轻量级路径)
操作指南
步骤 1: 设置 Bright Data SERP 区域
Bright Data 需要在仪表板中创建 SERP API 区域、配置代理凭据、将服务器 IP 列入白名单并选择计费计划(SERP API 最低 499 美元/月)。您会收到区域用户名、密码和主机。
# Bright Data setup (after dashboard configuration)
import requests
BD_HOST = 'brd.superproxy.io'
BD_PORT = 33335
BD_USER = 'brd-customer-CUST_ID-zone-ZONE_NAME'
BD_PASS = 'your_zone_password'
proxies = {
'http': f'http://{BD_USER}:{BD_PASS}@{BD_HOST}:{BD_PORT}',
'https': f'http://{BD_USER}:{BD_PASS}@{BD_HOST}:{BD_PORT}'
}
# Bright Data SERP request
resp = requests.get(
'https://www.google.com/search?q=best+crm+2026&gl=us',
proxies=proxies,
verify=False # Required for BD proxy
)
print(f'Status: {resp.status_code}, Length: {len(resp.text)}')
# You still need to parse raw HTML yourself步骤 2: 设置轻量级 API 替代方案
使用轻量级搜索 API,无需区域配置、无需代理管理、无需 IP 白名单。您获得 API 密钥并立即开始查询。响应是结构化 JSON,而不是原始 HTML。
import requests, os
API_KEY = os.environ.get('SCAVIO_API_KEY', 'your_scavio_api_key')
resp = requests.post(
'https://api.scavio.dev/api/v1/search',
headers={'x-api-key': API_KEY, 'Content-Type': 'application/json'},
json={'query': 'best crm 2026', 'country_code': 'us'}
)
data = resp.json()
for r in data.get('organic_results', [])[:3]:
print(f"{r['title']} -> {r['link']}")步骤 3: 比较响应格式
Bright Data 返回原始 Google HTML,您必须使用 BeautifulSoup 或自定义解析器对其进行解析。轻量级 API 返回结构化 JSON,其中包含已提取的organic_results、featured_snippets 和 people_also_ask。
# Bright Data: you must parse HTML yourself
from bs4 import BeautifulSoup
soup = BeautifulSoup(bd_response.text, 'html.parser')
results = []
for div in soup.select('div.g'):
title = div.select_one('h3')
link = div.select_one('a')
if title and link:
results.append({'title': title.text, 'link': link['href']})
# Fragile: selector changes break this regularly
# Lightweight API: structured JSON out of the box
organic = data.get('organic_results', [])
snippets = data.get('featured_snippets', [])
paa = data.get('people_also_ask', [])
print(f'{len(organic)} results, {len(snippets)} snippets, {len(paa)} PAA')步骤 4: 比较不同数量的成本
计算常见查询量下这两个选项的每月成本。 Bright Data SERP API 起价为 499 美元/月。轻量级 API 收费 0.005 美元/积分,每月免费 250 个积分,计划起价为 30/7K 积分。
volumes = [1000, 5000, 10000, 50000]
print(f'{"Queries/mo":<12} {"Bright Data":<15} {"Scavio":<15} {"Savings"}')
print('-' * 55)
for v in volumes:
bd_cost = max(499, v * 0.01) # ~$0.01/query on SERP API
# Scavio: $0.005/credit, 1 credit per query
if v <= 250:
sc_cost = 0
elif v <= 7000:
sc_cost = 30
elif v <= 28000:
sc_cost = 100
elif v <= 85000:
sc_cost = 250
else:
sc_cost = 500
savings = bd_cost - sc_cost
print(f'{v:<12} ${bd_cost:<14.0f} ${sc_cost:<14} ${savings:.0f}')Python 示例
import requests, os, time
API_KEY = os.environ.get('SCAVIO_API_KEY', 'your_scavio_api_key')
ENDPOINT = 'https://api.scavio.dev/api/v1/search'
HEADERS = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}
def lightweight_search(query: str, country: str = 'us') -> dict:
start = time.time()
resp = requests.post(ENDPOINT, headers=HEADERS,
json={'query': query, 'country_code': country})
resp.raise_for_status()
elapsed = time.time() - start
data = resp.json()
return {
'query': query,
'results': len(data.get('organic_results', [])),
'snippets': len(data.get('featured_snippets', [])),
'paa': len(data.get('people_also_ask', [])),
'latency_ms': round(elapsed * 1000)
}
queries = ['best crm 2026', 'crm pricing comparison', 'hubspot vs salesforce']
for q in queries:
stats = lightweight_search(q)
print(f"{stats['query']}: {stats['results']} results in {stats['latency_ms']}ms")
print(f" Snippets: {stats['snippets']}, PAA: {stats['paa']}")JavaScript 示例
const API_KEY = process.env.SCAVIO_API_KEY || 'your_scavio_api_key';
const ENDPOINT = 'https://api.scavio.dev/api/v1/search';
const HEADERS = { 'x-api-key': API_KEY, 'Content-Type': 'application/json' };
async function lightweightSearch(query, country = 'us') {
const start = Date.now();
const resp = await fetch(ENDPOINT, {
method: 'POST',
headers: HEADERS,
body: JSON.stringify({ query, country_code: country })
});
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const data = await resp.json();
return {
query,
results: (data.organic_results || []).length,
snippets: (data.featured_snippets || []).length,
paa: (data.people_also_ask || []).length,
latencyMs: Date.now() - start
};
}
async function main() {
const queries = ['best crm 2026', 'crm pricing comparison', 'hubspot vs salesforce'];
for (const q of queries) {
const stats = await lightweightSearch(q);
console.log(`${stats.query}: ${stats.results} results in ${stats.latencyMs}ms`);
console.log(` Snippets: ${stats.snippets}, PAA: ${stats.paa}`);
}
}
main().catch(console.error);预期输出
Queries/mo Bright Data Scavio Savings
-------------------------------------------------------
1000 $499 $30 $469
5000 $499 $30 $469
10000 $499 $100 $399
50000 $500 $250 $250
best crm 2026: 10 results in 820ms
Snippets: 1, PAA: 4
crm pricing comparison: 10 results in 750ms
Snippets: 0, PAA: 3
hubspot vs salesforce: 10 results in 680ms
Snippets: 1, PAA: 5