在 Google I/O 2026 之后,AI 模式将为 1B+ 用户提供引用(或跳过)您的内容的生成答案。此仪表板跟踪关键字的每日 AI 模式可见性、显示趋势线并在引用率下降时发出警报。它按每日 cron 运行,价格为 0.025 美元/天,运行 5 个关键字。
前置条件
- Python 3.8+
- 请求库
- 来自 scavio.dev 的 Scavio API 密钥
- Flask 或任何用于仪表板的 Web 框架
操作指南
步骤 1: 构建日常扫描管道
每天扫描目标关键词并存储AI模式引文数据。
Python
import os, requests, json
from datetime import datetime, timedelta
API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}
KEYWORDS = [
'best search api for agents',
'mcp search tool setup',
'web search api pricing 2026',
'serp api for ai apps',
'search api free tier',
]
BRAND = 'Scavio'
DB_FILE = 'ai_mode_dashboard.json'
def scan_keyword(keyword, brand):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': keyword, 'country_code': 'us'}, timeout=10).json()
ai = data.get('ai_overview', data.get('answer_box', {}))
organic = data.get('organic_results', [])
brand_l = brand.lower()
return {
'keyword': keyword,
'has_ai': bool(ai),
'cited_in_ai': brand_l in json.dumps(ai).lower() if ai else False,
'organic_pos': next((i+1 for i, r in enumerate(organic) if brand_l in r.get('link', '').lower()), None),
'top_cited': [r.get('displayed_link', '')[:30] for r in organic[:3]],
}
def daily_scan():
today = datetime.now().strftime('%Y-%m-%d')
scans = [scan_keyword(kw, BRAND) for kw in KEYWORDS]
cited = sum(1 for s in scans if s['cited_in_ai'])
has_ai = sum(1 for s in scans if s['has_ai'])
score = (cited / has_ai * 100) if has_ai else 0
record = {'date': today, 'score': score, 'cited': cited, 'total_ai': has_ai, 'scans': scans}
# Append to history
try:
with open(DB_FILE) as f:
history = json.load(f)
except FileNotFoundError:
history = []
history.append(record)
with open(DB_FILE, 'w') as f:
json.dump(history, f, indent=2)
print(f'Daily scan: {today} | Score: {score:.0f}% | Cited: {cited}/{has_ai}')
return record
record = daily_scan()步骤 2: 构建趋势分析
比较每日快照以显示可见度趋势的上升或下降。
Python
def analyze_trends(db_file=DB_FILE):
with open(db_file) as f:
history = json.load(f)
if len(history) < 2:
print(' Need at least 2 days of data for trends.')
return
print(f'\n=== AI Mode Visibility Trends ===')
print(f' Period: {history[0]["date"]} to {history[-1]["date"]} ({len(history)} days)')
# Score trend
scores = [h['score'] for h in history]
latest = scores[-1]
prev = scores[-2]
avg_7d = sum(scores[-7:]) / min(len(scores), 7)
delta = latest - prev
direction = 'UP' if delta > 0 else 'DOWN' if delta < 0 else 'STABLE'
print(f'\n Today: {latest:.0f}%')
print(f' Change: {delta:+.0f}% ({direction})')
print(f' 7d avg: {avg_7d:.0f}%')
# Keyword-level changes
today_scans = {s['keyword']: s for s in history[-1]['scans']}
prev_scans = {s['keyword']: s for s in history[-2]['scans']}
print(f'\n Keyword Changes:')
for kw, scan in today_scans.items():
prev_scan = prev_scans.get(kw, {})
if scan['cited_in_ai'] != prev_scan.get('cited_in_ai', False):
change = 'GAINED' if scan['cited_in_ai'] else 'LOST'
print(f' {change}: {kw[:40]}')
# Chart (ASCII)
print(f'\n Score History:')
for h in history[-14:]:
bar = '#' * int(h['score'] / 5)
print(f' {h["date"]} | {bar:20} {h["score"]:.0f}%')
analyze_trends()步骤 3: 通过 Flask 提供仪表板
创建一个简单的 Web 仪表板来查看趋势和关键字详细信息。
Python
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/api/dashboard')
def dashboard():
try:
with open(DB_FILE) as f:
history = json.load(f)
except FileNotFoundError:
return jsonify({'error': 'No data yet. Run daily_scan() first.'})
latest = history[-1] if history else {}
scores = [{'date': h['date'], 'score': h['score']} for h in history]
return jsonify({
'latest_score': latest.get('score', 0),
'latest_date': latest.get('date', ''),
'cited': latest.get('cited', 0),
'total_ai': latest.get('total_ai', 0),
'history': scores[-30:],
'keywords': latest.get('scans', []),
'cost_per_day': f'${len(KEYWORDS) * 0.005:.3f}',
})
@app.route('/api/gaps')
def gaps():
with open(DB_FILE) as f:
history = json.load(f)
latest = history[-1] if history else {}
gap_keywords = [s['keyword'] for s in latest.get('scans', []) if s.get('has_ai') and not s.get('cited_in_ai')]
return jsonify({'gaps': gap_keywords, 'count': len(gap_keywords)})
# Uncomment to run:
# app.run(port=5050)
print('Dashboard API ready on :5050')
print(' GET /api/dashboard - Overview and trends')
print(' GET /api/gaps - Keywords where AI Mode skips you')
print(f' Daily cost: ${len(KEYWORDS) * 0.005:.3f}')Python 示例
Python
import os, requests, json
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}
def ai_visibility(keywords, brand):
cited = 0
for kw in keywords:
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': kw, 'country_code': 'us'}, timeout=10).json()
ai = data.get('ai_overview', data.get('answer_box', {}))
if ai and brand.lower() in json.dumps(ai).lower():
cited += 1
print(f' CITED: {kw}')
else:
print(f' ABSENT: {kw}')
print(f'Score: {cited}/{len(keywords)} ({cited/len(keywords)*100:.0f}%)')
ai_visibility(['best search api', 'mcp search tool'], 'Scavio')JavaScript 示例
JavaScript
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
let cited = 0;
const keywords = ['best search api', 'mcp search tool'];
for (const kw of keywords) {
const data = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: SH,
body: JSON.stringify({ query: kw, country_code: 'us' })
}).then(r => r.json());
const ai = data.ai_overview || data.answer_box || {};
if (JSON.stringify(ai).toLowerCase().includes('scavio')) cited++;
}
console.log(`AI Mode visibility: ${cited}/${keywords.length}`);预期输出
JSON
Daily scan: 2026-05-21 | Score: 50% | Cited: 2/4
=== AI Mode Visibility Trends ===
Period: 2026-05-14 to 2026-05-21 (7 days)
Today: 50%
Change: +10% (UP)
7d avg: 42%
Score History:
2026-05-14 | ######## 40%
2026-05-15 | ######## 40%
2026-05-18 | ######### 45%
2026-05-21 | ########## 50%
Dashboard API ready on :5050