品牌监控对于声誉管理、公关响应和竞争情报至关重要。了解您的品牌何时在 Google 新闻、自然搜索结果和 YouTube 中被提及,有助于您快速响应报道并衡量营销活动的影响。本教程构建了一个多平台品牌监控脚本,用于查询 Google 和 YouTube 的品牌提及情况、删除重复结果并发送新提及的每日摘要。
前置条件
- Python 3.8 或更高版本
- 请求已安装库
- Scavio API 密钥
- 要跟踪的品牌名称和可选竞争对手名称
操作指南
步骤 1: 定义要监控的品牌
设置要跟踪的品牌名称和变体列表。包括常见的拼写错误或相关的产品名称。
Python
BRANDS = ["Scavio", "scavio.dev", "Scavio API"]
MONITOR_COMPETITORS = ["SerpAPI", "Bright Data"]步骤 2: 获取 Google 提及
向 Google 查询每个品牌名称,并收集有机结果和新闻结果作为提及候选者。
Python
def google_mentions(brand: str) -> list[dict]:
data = search_google(brand)
mentions = data.get("organic_results", [])
mentions += data.get("news_results", [])
return [{"source": "google", "title": m.get("title"), "link": m.get("link"), "date": m.get("date")} for m in mentions]步骤 3: 获取 YouTube 提及
在 YouTube 上搜索每个品牌名称并收集视频标题和 URL 作为提及。
Python
def youtube_mentions(brand: str) -> list[dict]:
r = requests.post(
"https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"platform": "youtube", "query": brand}
)
r.raise_for_status()
videos = r.json().get("videos", [])
return [{"source": "youtube", "title": v.get("title"), "link": v.get("url"), "date": v.get("published_at")} for v in videos]步骤 4: 合并和重复数据删除
合并 Google 和 YouTube 提及内容、按 URL 删除重复内容并按日期排序。
Python
def collect_mentions(brand: str) -> list[dict]:
mentions = google_mentions(brand) + youtube_mentions(brand)
seen = {}
for m in mentions:
if m["link"] not in seen:
seen[m["link"]] = m
return list(seen.values())Python 示例
Python
import os
import requests
API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")
ENDPOINT = "https://api.scavio.dev/api/v1/search"
BRANDS = ["Scavio", "Scavio API"]
def search(platform: str, query: str, extra: dict = {}) -> dict:
body = {"platform": platform, "query": query, **extra} if platform != "google" else {"query": query, "country_code": "us"}
r = requests.post(ENDPOINT, headers={"x-api-key": API_KEY}, json=body)
r.raise_for_status()
return r.json()
def monitor(brand: str) -> list[dict]:
g = search("google", brand)
y = search("youtube", brand)
mentions = []
for m in g.get("organic_results", [])[:5]:
mentions.append({"src": "google", "title": m.get("title"), "url": m.get("link")})
for v in y.get("videos", [])[:5]:
mentions.append({"src": "youtube", "title": v.get("title"), "url": v.get("url")})
return mentions
if __name__ == "__main__":
for brand in BRANDS:
print(f"\n=== {brand} ===")
for m in monitor(brand):
print(f"[{m['src']}] {m['title']}")JavaScript 示例
JavaScript
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";
const ENDPOINT = "https://api.scavio.dev/api/v1/search";
const BRANDS = ["Scavio", "Scavio API"];
async function search(platform, query) {
const body = platform === "google" ? { query, country_code: "us" } : { platform, query };
const res = await fetch(ENDPOINT, {
method: "POST",
headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
body: JSON.stringify(body)
});
return res.json();
}
async function monitor(brand) {
const [g, y] = await Promise.all([search("google", brand), search("youtube", brand)]);
const mentions = [];
(g.organic_results || []).slice(0, 5).forEach(m => mentions.push({ src: "google", title: m.title, url: m.link }));
(y.videos || []).slice(0, 5).forEach(v => mentions.push({ src: "youtube", title: v.title, url: v.url }));
return mentions;
}
async function main() {
for (const brand of BRANDS) {
console.log(`\n=== ${brand} ===`);
const m = await monitor(brand);
m.forEach(item => console.log(`[${item.src}] ${item.title}`));
}
}
main().catch(console.error);预期输出
JSON
=== Scavio ===
[google] Scavio Review: Real-Time Search API for AI Agents
[google] Scavio vs SerpAPI: Which Is Better in 2026?
[youtube] I Built an AI Agent with Scavio - Full Tutorial
[youtube] Scavio API vs Bright Data Comparison