如何使用 TalorData 抓取 Google Trends 搜索结果
了解如何使用 TalorData SERP API 抓取 Google Trends 搜索结果。本技术指南涵盖了查询参数、Python requests 请求、时间趋势、地区数据、相关查询、相关主题、CSV 导出以及常见错误。
Google Trends 很适合用来观察搜索需求的变化。它能帮你在排名、流量、销售或客服问题出现之前,先看到用户注意力正在往哪里移动。
对 SEO 和内容团队来说,它可以回答这些问题:
|
问题 |
为什么重要 |
|
这个主题是在增长还是衰退? |
内容规划 |
|
哪个地区的兴趣更强? |
Local SEO 和市场研究 |
|
哪些相关查询正在上升? |
关键词发现 |
|
哪些 topics 和这个查询有关? |
Topic clustering |
|
需求是否有季节性? |
Campaign planning |
|
哪个产品或品牌正在获得关注? |
Competitive monitoring |
问题是,Google Trends 更像是一个互动界面,不是干净的数据管线。如果你要做重复采集、dashboard、alerts 或 AI workflows,手动查看 Trends 网站不够。
这时就需要 Google Trends SERP API workflow。
通过 TalorData,你可以在 SERP API layer 中请求 Google Trends data,设置 query、category、date range、location、search type 和 output options,并将结果解析成结构化数据。TalorData 的 Google Trends 参数指南列出 q 为必填搜索查询,并包含 category、date 等 Google Trends request 设置。
可以从 Google Trends 采集什么?
Google Trends data 和一般 Google Search ranking data 不一样。你不是在采集 title、URL、snippet、position 这类 organic results。
你采集的是趋势信号。
常见数据类型包括:
|
Data type |
说明 |
|
Interest over time |
搜索兴趣如何随时间变化 |
|
Interest by region |
哪些地区更热门 |
|
Related queries |
和关键词相关的搜索词 |
|
Related topics |
和关键词相关的 topics |
|
Rising queries |
快速增长的查询 |
|
Top queries |
最相关的热门查询 |
Google Trends 网站本身也将 Trends 定位为按时间、地点和热度探索搜索兴趣的工具。
常见技术场景包括:
|
使用场景 |
示例 |
|
SEO topic research |
追踪 “AI agent workflow” 是否增长 |
|
Content planning |
找 “Google Trends API” 的 rising questions |
|
Market research |
比较不同国家的需求 |
|
Product research |
观察品牌或品类热度 |
|
Local strategy |
看哪些地区更常搜索某主题 |
|
AI agents |
让 agent 在写报告前先检测趋势 |
基本请求结构
实际 endpoint 和 authentication 格式,请以你的 TalorData dashboard 或 API docs 为准。
一个典型请求长这样:
POST TALORDATA_SERP_ENDPOINT
Authorization: Bearer TALORDATA_API_KEY
Content-Type: application/json
{
"engine": "google_trends",
"q": "coffee",
"date": "today 12-m",
"geo": "US",
"cat": "0",
"data_type": "TIMESERIES"
}
核心参数:
|
Parameter |
Purpose |
|
|
选择 Google Trends |
|
|
搜索查询 |
|
|
时间范围 |
|
|
地理位置 |
|
|
类别 |
|
|
返回哪一类 Trends data |
|
|
Timezone offset |
|
|
搜索属性,例如 web、news、images、shopping、YouTube |
Google Trends 工具通常使用 TIMESERIES、GEO_MAP、RELATED_QUERIES 和 RELATED_TOPICS 来表示 interest over time、region interest、related queries 和 related topics。
Step 1:准备 API key
将 TalorData API key 和 endpoint 存成环境变量。
export TALORDATA_API_KEY="your_api_key_here"
export TALORDATA_SERP_ENDPOINT="your_talordata_serp_endpoint_here"
Windows PowerShell:
setx TALORDATA_API_KEY "your_api_key_here"
setx TALORDATA_SERP_ENDPOINT "your_talordata_serp_endpoint_here"
安装 Python dependencies:
pip install requests pandas
Step 2:建立可复用 Python client
下面这个 function 会发送 Google Trends request 并返回 JSON。
import os
import requests
from typing import Any, Dict, Optional
TALORDATA_API_KEY = os.getenv("TALORDATA_API_KEY")
TALORDATA_SERP_ENDPOINT = os.getenv("TALORDATA_SERP_ENDPOINT")
def fetch_google_trends(
query: str,
data_type: str = "TIMESERIES",
geo: str = "US",
date: str = "today 12-m",
cat: str = "0",
tz: str = "420",
gprop: Optional[str] = None
) -> Dict[str, Any]:
"""
Fetch Google Trends data with TalorData SERP API.
Replace the request body or headers if your TalorData dashboard
shows a different authentication format.
"""
if not TALORDATA_API_KEY:
raise RuntimeError("Missing TALORDATA_API_KEY environment variable.")
if not TALORDATA_SERP_ENDPOINT:
raise RuntimeError("Missing TALORDATA_SERP_ENDPOINT environment variable.")
payload = {
"engine": "google_trends",
"q": query,
"data_type": data_type,
"geo": geo,
"date": date,
"cat": cat,
"tz": tz
}
if gprop:
payload["gprop"] = gprop
headers = {
"Authorization": f"Bearer {TALORDATA_API_KEY}",
"Content-Type": "application/json"
}
response = requests.post(
TALORDATA_SERP_ENDPOINT,
json=payload,
headers=headers,
timeout=30
)
response.raise_for_status()
return response.json()
使用方式:
if __name__ == "__main__":
data = fetch_google_trends(
query="AI agents",
data_type="TIMESERIES",
geo="US",
date="today 12-m"
)
print(data)
Step 3:获取 interest over time
Interest over time 通常是最常用的 Google Trends chart。
它可以回答:
|
问题 |
示例 |
|
需求是否增长? |
“AI agents” 过去 12 个月是否上升 |
|
是否有季节性? |
“Halloween costume” 每年 10 月是否上升 |
|
活动是否带来热度? |
品牌词在发布后是否上升 |
|
热度是否衰退? |
新闻周期后主题是否冷却 |
请求:
data = fetch_google_trends(
query="AI agents",
data_type="TIMESERIES",
geo="US",
date="today 12-m"
)
常见 response 会包含 timeline array,例如 date、timestamp 和 values。
{
"interest_over_time": {
"timeline_data": [
{
"date": "Jan 1–7, 2026",
"timestamp": "1767225600",
"values": [
{
"value": "72",
"extracted_value": 72
}
]
}
]
}
}
Parser:
from typing import Any, Dict, List
def parse_interest_over_time(data: Dict[str, Any]) -> List[Dict[str, Any]]:
timeline = (
data.get("interest_over_time", {})
.get("timeline_data", [])
)
rows = []
for item in timeline:
values = item.get("values", [])
if not values:
continue
first_value = values[0]
rows.append({
"date": item.get("date"),
"timestamp": item.get("timestamp"),
"value": first_value.get("value"),
"extracted_value": first_value.get("extracted_value")
})
return rows
保存成 CSV:
import pandas as pd
data = fetch_google_trends(
query="AI agents",
data_type="TIMESERIES",
geo="US",
date="today 12-m"
)
rows = parse_interest_over_time(data)
df = pd.DataFrame(rows)
df.to_csv("google_trends_interest_over_time.csv", index=False)
print(df.head())
Step 4:比较多个 keywords
Google Trends 常常在比较关键词时更有价值。
data = fetch_google_trends(
query="AI agents,RAG,LLM apps",
data_type="TIMESERIES",
geo="US",
date="today 12-m"
)
适合比较:
|
Comparison |
用途 |
|
Brand vs competitor |
市场需求 |
|
Topic A vs topic B |
内容优先级 |
|
Old term vs new term |
语言变化 |
|
Product category vs feature |
用户意图 |
|
Keyword variants |
SEO targeting |
注意:Trends values 通常是 indexed values,不是绝对搜索量。Google Search Central blog 说明,Trends data 反映的是 search interest,不是绝对数字。
所以 100 不等于 100 次搜索,而是所选范围内的最高相对热度。
Step 5:获取 interest by region
Regional data 可以告诉你某个 topic 在哪些地区更强。
data = fetch_google_trends(
query="electric bike",
data_type="GEO_MAP",
geo="US",
date="today 12-m"
)
适合:
|
使用场景 |
示例 |
|
Local SEO |
哪些州更常搜索 “emergency plumber”? |
|
Market expansion |
哪里的 “EV charger installation” 正在增长? |
|
Ad planning |
哪些地区值得投放? |
|
Content localization |
不同国家用什么词? |
|
Product demand |
哪些地区品类需求更高? |
Parser:
def parse_geo_map(data: Dict[str, Any]) -> List[Dict[str, Any]]:
geo_data = data.get("interest_by_region", [])
rows = []
for item in geo_data:
rows.append({
"location": item.get("location"),
"geo_code": item.get("geo_code"),
"value": item.get("value"),
"extracted_value": item.get("extracted_value")
})
return rows
因为不同 response structure 可能不同,建议先检查 raw response:
import json
print(json.dumps(data, indent=2, ensure_ascii=False)[:3000])
先用小手电筒照一下洞口,后面就不容易在数据洞穴里撞墙。
Step 6:获取 related queries
Related queries 很适合做 keyword discovery。
data = fetch_google_trends(
query="google trends api",
data_type="RELATED_QUERIES",
geo="US",
date="today 12-m"
)
常见分组:
|
Group |
Meaning |
|
Top |
与查询最相关的搜索词 |
|
Rising |
快速增长的搜索词 |
用途:
|
Workflow |
用法 |
|
SEO keyword research |
找 long-tail terms |
|
Content planning |
找文章主题 |
|
Product marketing |
发现用户语言 |
|
Competitive research |
观察相邻需求 |
|
AI agents |
生成新的研究方向 |
Parser:
def parse_related_queries(data: Dict[str, Any]) -> List[Dict[str, Any]]:
related = data.get("related_queries", {})
rows = []
for group_name in ["top", "rising"]:
for item in related.get(group_name, []):
rows.append({
"group": group_name,
"query": item.get("query"),
"value": item.get("value"),
"extracted_value": item.get("extracted_value"),
"link": item.get("link")
})
return rows
保存 CSV:
data = fetch_google_trends(
query="google trends api",
data_type="RELATED_QUERIES",
geo="US",
date="today 12-m"
)
rows = parse_related_queries(data)
pd.DataFrame(rows).to_csv("related_queries.csv", index=False)
Step 7:获取 related topics
Related topics 适合处理语义模糊的词。
例如 “python” 可能是 programming language,也可能是 snake。Topic data 可以帮你理解查询周围的语义环境。
data = fetch_google_trends(
query="python",
data_type="RELATED_TOPICS",
geo="US",
date="today 12-m"
)
Parser:
def parse_related_topics(data: Dict[str, Any]) -> List[Dict[str, Any]]:
related = data.get("related_topics", {})
rows = []
for group_name in ["top", "rising"]:
for item in related.get(group_name, []):
topic = item.get("topic", {})
rows.append({
"group": group_name,
"topic_title": topic.get("title"),
"topic_type": topic.get("type"),
"topic_id": topic.get("value") or item.get("id"),
"value": item.get("value"),
"extracted_value": item.get("extracted_value"),
"link": item.get("link")
})
return rows
适合:
|
使用场景 |
示例 |
|
Entity SEO |
理解 related entities |
|
Topic clustering |
建 content hubs |
|
AI search |
把 related topics 喂给 agent |
|
Market research |
发现相邻品类 |
|
Brand research |
看品牌周围的 topics |
Step 8:使用 categories
cat 参数可以按 category 限定查询。TalorData Google Trends 参数指南将 cat 列为 optional category parameter,默认值为 0,表示 all categories。
data = fetch_google_trends(
query="apple",
data_type="TIMESERIES",
geo="US",
date="today 12-m",
cat="5"
)
对语义模糊词很有用:
|
Query |
可能含义 |
|
apple |
水果、公司、音乐、设备 |
|
jaguar |
动物、汽车品牌、球队 |
|
python |
蛇、编程语言 |
|
java |
咖啡、岛屿、编程语言 |
Category 可以降低噪声。
Step 9:使用 search properties
gprop 常用于指定 Google property:
|
|
Meaning |
|
empty |
Web Search |
|
|
Image Search |
|
|
News Search |
|
|
Google Shopping |
|
|
YouTube Search |
示例:
# News interest
data = fetch_google_trends(
query="AI regulation",
data_type="TIMESERIES",
geo="US",
date="today 3-m",
gprop="news"
)
# YouTube interest
data = fetch_google_trends(
query="python tutorial",
data_type="TIMESERIES",
geo="US",
date="today 12-m",
gprop="youtube"
)
对 SEO 来说,这很重要。某个 topic 在 web search 上可能平稳,但在 YouTube 或 News 里正在上升。
Step 10:完整 script
下面是一个完整示例,会采集 interest over time 和 related queries。
import os
import json
import requests
import pandas as pd
from typing import Any, Dict, List, Optional
TALORDATA_API_KEY = os.getenv("TALORDATA_API_KEY")
TALORDATA_SERP_ENDPOINT = os.getenv("TALORDATA_SERP_ENDPOINT")
def fetch_google_trends(
query: str,
data_type: str = "TIMESERIES",
geo: str = "US",
date: str = "today 12-m",
cat: str = "0",
tz: str = "420",
gprop: Optional[str] = None
) -> Dict[str, Any]:
if not TALORDATA_API_KEY:
raise RuntimeError("Missing TALORDATA_API_KEY environment variable.")
if not TALORDATA_SERP_ENDPOINT:
raise RuntimeError("Missing TALORDATA_SERP_ENDPOINT environment variable.")
payload = {
"engine": "google_trends",
"q": query,
"data_type": data_type,
"geo": geo,
"date": date,
"cat": cat,
"tz": tz
}
if gprop:
payload["gprop"] = gprop
response = requests.post(
TALORDATA_SERP_ENDPOINT,
json=payload,
headers={
"Authorization": f"Bearer {TALORDATA_API_KEY}",
"Content-Type": "application/json"
},
timeout=30
)
response.raise_for_status()
return response.json()
def parse_interest_over_time(data: Dict[str, Any]) -> List[Dict[str, Any]]:
timeline = data.get("interest_over_time", {}).get("timeline_data", [])
rows = []
for item in timeline:
values = item.get("values", [])
if not values:
continue
first_value = values[0]
rows.append({
"date": item.get("date"),
"timestamp": item.get("timestamp"),
"value": first_value.get("value"),
"extracted_value": first_value.get("extracted_value")
})
return rows
def parse_related_queries(data: Dict[str, Any]) -> List[Dict[str, Any]]:
related = data.get("related_queries", {})
rows = []
for group_name in ["top", "rising"]:
for item in related.get(group_name, []):
rows.append({
"group": group_name,
"query": item.get("query"),
"value": item.get("value"),
"extracted_value": item.get("extracted_value"),
"link": item.get("link")
})
return rows
def main() -> None:
query = "google trends api"
trend_data = fetch_google_trends(
query=query,
data_type="TIMESERIES",
geo="US",
date="today 12-m"
)
trend_rows = parse_interest_over_time(trend_data)
pd.DataFrame(trend_rows).to_csv("interest_over_time.csv", index=False)
related_data = fetch_google_trends(
query=query,
data_type="RELATED_QUERIES",
geo="US",
date="today 12-m"
)
related_rows = parse_related_queries(related_data)
pd.DataFrame(related_rows).to_csv("related_queries.csv", index=False)
with open("raw_google_trends_response.json", "w", encoding="utf-8") as file:
json.dump({
"timeseries": trend_data,
"related_queries": related_data
}, file, ensure_ascii=False, indent=2)
print("Saved interest_over_time.csv")
print("Saved related_queries.csv")
print("Saved raw_google_trends_response.json")
if __name__ == "__main__":
main()
如何使用这些数据?
当 Google Trends data 变成 CSV 或 JSON 之后,可以放进很多流程:
|
Workflow |
Trends data 如何帮助 |
|
SEO planning |
优先做增长中的 topics |
|
Content calendar |
按季节需求安排文章 |
|
Competitor monitoring |
比较品牌兴趣 |
|
Product research |
发现品类增长 |
|
Local marketing |
选择目标地区 |
|
AI agents |
把 trend signals 喂给 planning tasks |
|
RAG pipelines |
把 trend snapshots 存成 structured context |
示例内容流程:
Google Trends API
↓
Collect related rising queries
↓
Cluster queries by topic
↓
Check SERP competition
↓
Generate content brief
↓
Track performance over time
Trends data 不应该取代 keyword volume、ranking data 或 conversion data。它是一层信号。用得好,它能在流量报表敲门前,提前告诉你注意力正在往哪里跑。
常见错误
把 Trends values 当成 search volume
Google Trends values 是 indexed interest scores,不是实际搜索次数。100 表示所选范围内的最高相对热度。
比较不同 requests 时不保存 context
一定要保存:
|
Context |
|
Query |
|
Geo |
|
Date range |
|
Category |
|
Search property |
|
Data type |
|
Timezone |
|
Collection timestamp |
没有 context,数字就会变成装饰用纸屑。
忽略 categories
语义模糊的词需要 category,否则可能混入无关 intent。
只看 interest over time
Related queries 和 related topics 往往对 SEO 和 content planning 更可执行。
不保存 raw responses
建立 parser 时,请保存 raw JSON。字段变化或 debug 时会很有用。
结语
使用 TalorData 抓取 Google Trends search results,本质上是把互动式 Trends 操作变成可重复的数据管线。
先从核心参数开始:
|
Parameter |
Start with |
|
|
Topic 或 keyword |
|
|
|
|
|
国家或地区 |
|
|
时间范围 |
|
|
类别 |
|
|
Web、news、images、shopping、YouTube |
|
|
Timezone offset |
接着把 response 解析成干净表格:interest over time、regional interest、related queries 和 related topics。
数据一旦结构化,就可以支撑 SEO planning、market research、dashboards、alerts 和 AI agents。
Google Trends 是搜索需求变成浪潮前的低语。好的 API workflow,能让你提前听见。立即免费测试Google Trends API