问题描述
当我从Google趋势查询中下载CSV时(例如,此处 ),我看到了
When I download a CSV from a Google trends query (e.g. here), I see a HTTP GET request to
https://www.google.com/trends/api/widgetdata/multiline/csv
带有参数
req:{"time":"2012-02-18 2017-02-18","resolution":"WEEK","locale":"en-GB","comparisonItem":[{"geo":{},"complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"trump"}]}}],"requestOptions":{"property":"","backend":"IZG","category":0}}
token:APP6_UEAAAAAWKm9N57FxjXrnfxhxhe5SEax6DyR97sY
tz:-120
req和tz参数很有意义,但是我不确定令牌是如何生成的.有人可以告诉我这是哪里来的吗?我需要使用oauth2软件包来创建这些令牌吗?
The req and tz params make sense, but I am unsure how the token is generated. Can someone explain to me where this comes from? Do I need to use oauth2 packages to create these tokens?
推荐答案
此令牌是为结果小部件生成的,每个小部件将具有自己的令牌.
This token is generated for result widgets, each widget will have its own token.
此令牌来自何处?
何时页面 https://trends.google.com/trends/explore?q = trump 已打开,Ajax GET
请求发送到 https://Trends.google.com/trends/api/explore ,其中包含查询参数:
When page https://trends.google.com/trends/explore?q=trump is opened, an Ajax GET
request is sent to https://trends.google.com/trends/api/explore, with query parameters:
在此Ajax请求的响应中,有一个widgets
字段,其中包含所有结果小部件数据.每个小部件都有一个唯一的令牌:
In the response of this Ajax request, there is a widgets
field which contains all result widget data. Each widget will have a unique token:
触发下载CSV 操作时(在特定窗口小部件上,GET
请求
When Download CSV operation is triggered (on specific widget, GET
request to
请注意响应中的令牌和csv下载请求中的令牌是相同的(对于同一小部件).
Please note the token in the response and the token in the download csv request is identical (for the same widget).
令牌是如何生成的?
从理论上讲,所有随机且唯一的字符串都可以用作保护窗口小部件的令牌. Google可能有自己的算法.
Theoretically, all random and unique string can be used as token to protect widget. Google may have its own algorithm.
这篇关于Google Trends API调用中的代币来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!