ScavioScavio
产品定价文档
登录开始使用
  1. 首页
  2. 教程
  3. 如何构建 AI 模式可见性仪表板
教程

如何构建 AI 模式可见性仪表板

构建一个仪表板,跟踪 2026 年 I/O 大会后 Google AI 模式中您的品牌提及情况。每日扫描、趋势图、差距警报。

获取免费API密钥API文档

在 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

相关教程

  • 如何通过 SERP API 跟踪 Google AI 模式响应
  • 如何检测 Google I/O 之后 AI 概述的变化
  • 如何构建自动化 GEO 可见性报告

常见问题

大多数开发者在15到30分钟内完成本教程。您需要一个Scavio API密钥(免费套餐即可)和可用的Python或JavaScript环境。

Python 3.8+. 请求库. 来自 scavio.dev 的 Scavio API 密钥. Flask 或任何用于仪表板的 Web 框架. Scavio API密钥注册即送50个免费积分。

可以。免费套餐注册即送50个积分,完全足够完成本教程并构建一个可运行的原型解决方案。

Scavio提供原生LangChain包(langchain-scavio)、MCP服务器以及适用于任何HTTP客户端的REST API。本教程使用 the raw REST API, 但您可以根据需要适配您选择的框架。

相关资源

Best Of

2026 年最佳 AI 生产力应用程序

Read more
Best Of

2026年最佳SerpAPI替代方案

Read more
Glossary

搜索 API 供应商格局(2026)

Read more
Glossary

搜索付费墙时代(2026)

Read more
Use Case

2026 开源 AI 网络访问方案

Read more
Comparison

DataForSEO vs Serper

Read more

开始构建

构建一个仪表板,跟踪 2026 年 I/O 大会后 Google AI 模式中您的品牌提及情况。每日扫描、趋势图、差距警报。

获取免费API密钥阅读文档
ScavioScavio

面向AI智能体的实时搜索API。搜索所有平台,不仅仅是Google。

产品

  • 功能
  • 定价
  • 控制台
  • 联盟计划

开发者

  • 文档
  • API参考
  • 快速开始
  • MCP集成
  • Python SDK

替代方案

  • Tavily替代方案
  • SerpAPI替代方案
  • Firecrawl替代方案
  • Exa替代方案

工具

  • JSON格式化
  • cURL转代码
  • Token计数器
  • 全部工具

© 2026 Scavio. 保留所有权利。

Featured on TAAFT
服务条款隐私政策