Google AI 概述(以前称为搜索生成体验)出现在许多信息查询的搜索结果顶部。他们将多个来源总结为一个简洁的答案,在有机结果之前可见。对于 SEO 专业人士和内容策略师来说,了解查询是否会触发 AI 概述及其内容对于了解流量影响变得越来越重要。当 Google 生成 SERP 响应时,Scadio API 会在 SERP 响应中返回 ai_overview 字段。本教程展示如何检测和提取 AI 概述内容。
前置条件
- Python 3.8 或更高版本
- 请求已安装库
- Scavio API 密钥
- 了解 SERP 功能和 SEO 基础知识
操作指南
步骤 1: 查询触发AI概览的主题
诸如“X 是如何工作的”或“Y 是什么”之类的信息查询通常会触发人工智能概述。将此类查询提交到 Scavio 端点。
data = search_google("how does retrieval augmented generation work")
ai_overview = data.get("ai_overview")
print("AI Overview present:", ai_overview is not None)步骤 2: 提取摘要文本
ai_overview 对象包含文本摘要和可选的引用来源列表。
if ai_overview:
print("Summary:")
print(ai_overview.get("text", "No text available"))
print("\nSources:")
for source in ai_overview.get("sources", []):
print(f" - {source.get('title')}: {source.get('link')}")步骤 3: 检查哪些查询触发 AI 概述
运行一批查询并报告哪些查询具有 AI 概述。这有助于确定 Google 正在总结哪些内容领域。
def check_ai_overviews(queries: list[str]) -> dict:
results = {}
for q in queries:
data = search_google(q)
results[q] = data.get("ai_overview") is not None
return results步骤 4: 保存 AI 概述数据以供分析
将 AI 概述内容和引用的来源保留为 JSON 以便进一步分析。
import json
overviews = {}
for q in queries:
data = search_google(q)
if data.get("ai_overview"):
overviews[q] = data["ai_overview"]
with open("ai_overviews.json", "w") as f:
json.dump(overviews, f, indent=2)Python 示例
import os
import json
import requests
API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")
ENDPOINT = "https://api.scavio.dev/api/v1/search"
def search_google(q: str) -> dict:
r = requests.post(ENDPOINT, headers={"x-api-key": API_KEY},
json={"query": q, "country_code": "us"})
r.raise_for_status()
return r.json()
def extract_ai_overviews(queries: list[str]) -> dict:
results = {}
for q in queries:
data = search_google(q)
ai = data.get("ai_overview")
results[q] = {"has_overview": ai is not None, "text": ai.get("text") if ai else None}
return results
if __name__ == "__main__":
queries = ["how does vector search work", "what is rag in ai", "python vs javascript 2026"]
overviews = extract_ai_overviews(queries)
print(json.dumps(overviews, indent=2))JavaScript 示例
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";
const ENDPOINT = "https://api.scavio.dev/api/v1/search";
async function searchGoogle(q) {
const res = await fetch(ENDPOINT, {
method: "POST",
headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({ query: q, country_code: "us" })
});
return res.json();
}
async function extractAIOverviews(queries) {
const results = {};
for (const q of queries) {
const data = await searchGoogle(q);
results[q] = { hasOverview: !!data.ai_overview, text: data.ai_overview?.text || null };
}
return results;
}
extractAIOverviews(["how does vector search work", "what is rag in ai"])
.then(r => console.log(JSON.stringify(r, null, 2)))
.catch(console.error);预期输出
{
"ai_overview": {
"text": "Retrieval-Augmented Generation (RAG) is a technique that enhances LLM responses by retrieving relevant documents from an external knowledge base before generating an answer...",
"sources": [
{ "title": "What is RAG? — AWS", "link": "https://aws.amazon.com/what-is/retrieval-augmented-generation/" },
{ "title": "RAG Explained — LangChain Blog", "link": "https://blog.langchain.dev/rag-explained" }
]
}
}