ScavioScavio
产品定价文档
登录开始使用
  1. 首页
  2. 教程
  3. 如何通过 SERP API 跟踪 Google AI 模式响应
教程

如何通过 SERP API 跟踪 Google AI 模式响应

监控 Google AI 模式何时在搜索结果中提及您的品牌。自动跟踪管道的价格为 0.005 美元/查询。

获取免费API密钥API文档

在 Google I/O 2026 之后,Google AI 模式现已拥有 1B+ 用户。当 AI 模式生成答案时,它可以引用您的网站或完全跳过它。本教程构建了一个跟踪器,用于监控您的品牌是否出现在目标关键字的 AI 模式响应中。每个关键字检查的费用为 0.005 美元。

前置条件

  • Python 3.8+
  • 请求库
  • 来自 scavio.dev 的 Scavio API 密钥
  • 要监控的目标关键字列表

操作指南

步骤 1: 检查 AI 模式信号的 SERP 结果

查询目标关键字并在响应中查找 AI 生成的内容。

Python
import os, requests, json
from datetime import datetime

API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}

BRAND = 'Scavio'
KEYWORDS = [
    'best search api for ai agents',
    'how to add search to ai agent',
    'mcp search tool',
    'serp api alternative',
    'web search api pricing',
]

def check_ai_mode(keyword, brand):
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=SH, json={'query': keyword, 'country_code': 'us'}, timeout=10).json()
    # Check AI overview / featured snippet
    ai_overview = data.get('ai_overview', data.get('answer_box', {}))
    organic = data.get('organic_results', [])
    featured = data.get('featured_snippet', {})
    brand_lower = brand.lower()
    in_ai = brand_lower in json.dumps(ai_overview).lower() if ai_overview else False
    in_featured = brand_lower in json.dumps(featured).lower() if featured else False
    in_organic = any(brand_lower in json.dumps(r).lower() for r in organic[:10])
    organic_pos = next((i+1 for i, r in enumerate(organic) if brand_lower in json.dumps(r).lower()), None)
    return {
        'keyword': keyword,
        'in_ai_mode': in_ai,
        'in_featured': in_featured,
        'in_organic': in_organic,
        'organic_position': organic_pos,
        'has_ai_overview': bool(ai_overview),
    }

print(f'Tracking AI Mode for "{BRAND}" across {len(KEYWORDS)} keywords\n')
results = []
for kw in KEYWORDS:
    r = check_ai_mode(kw, BRAND)
    results.append(r)
    ai_status = 'CITED' if r['in_ai_mode'] else 'ABSENT'
    org_status = f'#{r["organic_position"]}' if r['organic_position'] else 'absent'
    print(f'  {kw[:40]:40} | AI: {ai_status:6} | Organic: {org_status}')
print(f'\nCost: ${len(KEYWORDS) * 0.005:.3f}')

步骤 2: 计算 AI 模式可见度分数

将结果汇总为可见度分数,显示 AI 模式引用您品牌的频率。

Python
def ai_mode_visibility(results, brand):
    total = len(results)
    ai_cited = sum(1 for r in results if r['in_ai_mode'])
    featured = sum(1 for r in results if r['in_featured'])
    organic = sum(1 for r in results if r['in_organic'])
    has_ai = sum(1 for r in results if r['has_ai_overview'])
    ai_score = (ai_cited / has_ai * 100) if has_ai else 0
    overall_score = ((ai_cited * 3 + featured * 2 + organic) / (total * 3) * 100)
    print(f'\n=== AI Mode Visibility: {brand} ===')
    print(f'  Keywords tracked:    {total}')
    print(f'  AI Mode present:     {has_ai}/{total} queries')
    print(f'  Brand in AI Mode:    {ai_cited}/{has_ai} ({ai_score:.0f}%)')
    print(f'  Brand in Featured:   {featured}/{total}')
    print(f'  Brand in Organic:    {organic}/{total}')
    print(f'  Overall Visibility:  {overall_score:.0f}/100')
    # Gaps
    gaps = [r['keyword'] for r in results if r['has_ai_overview'] and not r['in_ai_mode']]
    if gaps:
        print(f'\n  AI Mode Gaps (present but not cited):')
        for g in gaps:
            print(f'    - {g}')
    return {'ai_score': ai_score, 'overall': overall_score, 'gaps': gaps}

visibility = ai_mode_visibility(results, BRAND)

步骤 3: 存储每日快照以进行趋势跟踪

保存每日可见性数据并随时间进行比较,以检测 Google I/O 大会后的变化。

Python
def save_daily_snapshot(results, visibility, output_file='ai_mode_tracking.json'):
    try:
        with open(output_file) as f:
            history = json.load(f)
    except FileNotFoundError:
        history = []
    snapshot = {
        'date': datetime.now().strftime('%Y-%m-%d'),
        'ai_score': visibility['ai_score'],
        'overall_score': visibility['overall'],
        'keywords_tracked': len(results),
        'ai_cited': sum(1 for r in results if r['in_ai_mode']),
        'details': results,
    }
    history.append(snapshot)
    with open(output_file, 'w') as f:
        json.dump(history, f, indent=2)
    # Trend analysis
    print(f'\n=== Trend ===')
    if len(history) >= 2:
        prev = history[-2]
        delta = snapshot['ai_score'] - prev['ai_score']
        direction = 'UP' if delta > 0 else 'DOWN' if delta < 0 else 'STABLE'
        print(f'  AI Score: {prev["ai_score"]:.0f} -> {snapshot["ai_score"]:.0f} ({direction} {abs(delta):.0f}pt)')
        print(f'  AI Citations: {prev["ai_cited"]} -> {snapshot["ai_cited"]}')
    else:
        print(f'  First snapshot saved. Run daily to track trends.')
    print(f'\n  Daily cost: ${len(results) * 0.005:.3f}')
    print(f'  Monthly cost: ${len(results) * 0.005 * 30:.2f}')

save_daily_snapshot(results, visibility)

Python 示例

Python
import os, requests, json
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}

def check_ai_mode(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', {}))
    cited = brand.lower() in json.dumps(ai).lower() if ai else False
    print(f'{keyword[:40]:40} | AI cited: {cited}')

check_ai_mode('best search api for agents', 'Scavio')

JavaScript 示例

JavaScript
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
const data = await fetch('https://api.scavio.dev/api/v1/search', {
  method: 'POST', headers: SH,
  body: JSON.stringify({ query: 'best search api for agents', country_code: 'us' })
}).then(r => r.json());
const ai = data.ai_overview || data.answer_box || {};
const cited = JSON.stringify(ai).toLowerCase().includes('scavio');
console.log(`AI Mode cited: ${cited}`);

预期输出

JSON
Tracking AI Mode for "Scavio" across 5 keywords

  best search api for ai agents            | AI: CITED  | Organic: #3
  how to add search to ai agent            | AI: ABSENT | Organic: #5
  mcp search tool                          | AI: CITED  | Organic: #2
  serp api alternative                     | AI: ABSENT | Organic: #4
  web search api pricing                   | AI: ABSENT | Organic: #7

Cost: $0.025

=== AI Mode Visibility: Scavio ===
  Keywords tracked:    5
  AI Mode present:     4/5 queries
  Brand in AI Mode:    2/4 (50%)
  Overall Visibility:  53/100

  Daily cost: $0.025
  Monthly cost: $0.75

相关教程

  • 如何构建 AI 模式可见性仪表板
  • 如何检测 Google I/O 之后 AI 概述的变化
  • 如何构建自动化 GEO 可见性报告

常见问题

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

Python 3.8+. 请求库. 来自 scavio.dev 的 Scavio API 密钥. 要监控的目标关键字列表. Scavio API密钥注册即送50个免费积分。

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

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

相关资源

Best Of

2026 年最佳基于队列的 SERP API

Read more
Best Of

Google I/O 2026 AI模式变化后最佳搜索API

Read more
Solution

从SERP API获取Google Ads数据

Read more
Comparison

Google CSE (Paid Tier) vs Third-Party SERP API (Scavio, SerpApi, Serper)

Read more
Glossary

SERP API

Read more
Glossary

Google Maps Places API成本

Read more

开始构建

监控 Google AI 模式何时在搜索结果中提及您的品牌。自动跟踪管道的价格为 0.005 美元/查询。

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

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

产品

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

开发者

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

替代方案

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

工具

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

© 2026 Scavio. 保留所有权利。

Featured on TAAFT
服务条款隐私政策