Google Search Console 会告诉您 Google 认为您的排名。实时 SERP 检查会告诉您现在的实际排名,包括 GSC 忽略的 SERP 功能。将两者结合起来可以发现,GSC 显示位置 3 的关键字,但由于 AI 概述压低了有机结果,实时结果显示位置 8。本教程通过实时 Scavio 检查和标记不匹配来验证 GSC 数据。
前置条件
- Python 3.10+
- google-auth 和 google-api-python-client
- 来自 scavio.dev 的 Scavio API 密钥
- 您网站的 GSC API 访问权限
操作指南
步骤 1: 从 GSC 中提取热门查询
验证并提取带有报告位置的热门查询。
Python
import os, requests
SK = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': SK, 'Content-Type': 'application/json'}
# Simulated GSC data (replace with real GSC API call)
gsc_data = [
{'query': 'serp api python', 'gsc_position': 3.2, 'clicks': 120},
{'query': 'web scraping api', 'gsc_position': 5.8, 'clicks': 85},
{'query': 'tiktok data api', 'gsc_position': 2.1, 'clicks': 200},
]步骤 2: 通过实时 SERP 检查进行验证
对于每个 GSC 查询,运行实时检查并比较位置。
Python
def live_rank(query, domain):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'country_code': 'us'}).json()
for r in data.get('organic_results', []):
if domain in r.get('link', ''): return r['position']
return None
def validate(gsc_data, domain='mysite.com'):
for row in gsc_data:
live = live_rank(row['query'], domain)
diff = live - row['gsc_position'] if live else None
flag = f' MISMATCH ({diff:+.0f})' if diff and abs(diff) >= 3 else ''
print(f" {row['query']:30} GSC: {row['gsc_position']:.1f} Live: {live or 'N/A'}{flag}")
print(f'Cost: ${len(gsc_data) * 0.005:.3f}')
validate(gsc_data)步骤 3: 检查导致不匹配的 SERP 功能
检测 AI 概述、PAA 框和推动有机向下的片段。
Python
def check_features(query):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'country_code': 'us'}).json()
features = []
if data.get('answer_box'): features.append('answer_box')
if data.get('ai_overview'): features.append('ai_overview')
if data.get('related_questions'): features.append(f"paa({len(data['related_questions'])})")
return features
for row in gsc_data:
features = check_features(row['query'])
if features: print(f" {row['query']}: {', '.join(features)}")步骤 4: 运行完整管道
结合 GSC 拉取、验证和特征分析。
Python
def run_pipeline():
print('Validating GSC data...')
validate(gsc_data)
print('\nSERP features affecting rankings:')
for row in gsc_data:
f = check_features(row['query'])
if f: print(f" {row['query']}: {', '.join(f)}")
print(f'\nTotal cost: ${len(gsc_data) * 2 * 0.005:.3f}')
run_pipeline()Python 示例
Python
import os, requests
SK = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': SK, 'Content-Type': 'application/json'}
def check(query, domain):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'country_code': 'us'}).json()
pos = next((r['position'] for r in data.get('organic_results', []) if domain in r.get('link', '')), None)
has_ao = bool(data.get('ai_overview'))
print(f'{query}: pos={pos}, ai_overview={has_ao}')
check('serp api python', 'mysite.com')JavaScript 示例
JavaScript
const SK = process.env.SCAVIO_API_KEY;
const SH = { 'x-api-key': SK, 'Content-Type': 'application/json' };
async function check(query, domain) {
const data = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: SH, body: JSON.stringify({ query, country_code: 'us' })
}).then(r => r.json());
const match = (data.organic_results || []).find(r => r.link.includes(domain));
console.log(`${query}: pos=${match?.position || 'N/A'}, ai=${!!data.ai_overview}`);
}
check('serp api python', 'mysite.com').catch(console.error);预期输出
JSON
serp api python GSC: 3.2 Live: 4
web scraping api GSC: 5.8 Live: 9 MISMATCH (+3)
tiktok data api GSC: 2.1 Live: 2
Cost: $0.015
web scraping api: ai_overview, paa(4)