【问题标题】:Google Trends API - data frequencyGoogle Trends API - 数据频率
【发布时间】:2018-09-12 20:06:01
【问题描述】:
我已获得对 Google Trends API 的访问权限,并尝试使用入门指南的代码下载一些趋势数据:
start_date = '2010-01'
end_date = '2018-01'
response = service.getGraph(terms='apple',restrictions_startDate=start_date,restrictions_endDate=end_date).execute()
pprint.pprint(response)
这将返回每月数据。有没有办法以每日频率获取数据?
【问题讨论】:
标签:
google-apis-explorer
google-trends
【解决方案1】:
Google Trends API 数据频率目前包括每周和每月频率,国家趋势订阅
Currently Weekly 是 Google Trends API 接受的最短时间,但未来可能会适用于每日时间尺度频率。
【解决方案3】:
getGraph 仅按周返回结果。要按天获取结果,请改用getTimelinesForHealth 并添加参数timelineResolution = 'day',如下所示:
response = service.getTimelinesForHealth(
terms = 'apple',
time_startDate = 'YYYY-MM-DD',
time_endDate = 'YYYY-MM-DD',
timelineResolution = 'day'
).execute()
注意restrictions_startDate 和restrictions_endDate 应该是
分别改为time_startDate和time_endDate,时间
以'YYYY-MM-DD'的格式表示。