如何获取用于从Google趋势下载CSV文件的*小工具令牌?

时间:2019-08-30 19:25:40

标签: python http python-requests http-get google-trends

我目前正尝试从Google趋势网站直接将数据检索到python中。通过检查“下载csv”按钮,我可以提取文件的基础URL,如下所示:

https://trends.google.com/trends/api/widgetdata/multiline/csv?req=%7B%22time%22%3A%222018-08-30%202019-08-30%22%2C%22resolution%22%3A%22WEEK%22%2C%22locale%22%3A%22de%22%2C%22comparisonItem%22%3A%5B%7B%22geo%22%3A%7B%7D%2C%22complexKeywordsRestriction%22%3A%7B%22keyword%22%3A%5B%7B%22type%22%3A%22BROAD%22%2C%22value%22%3A%22trump%22%7D%5D%7D%7D%5D%2C%22requestOptions%22%3A%7B%22property%22%3A%22%22%2C%22backend%22%3A%22IZG%22%2C%22category%22%3A0%7D%7D&token=APP6_UEAAAAAXWrEbGVLW-ssfeQvOJgr9938DRgYO1sm&tz=-120

未引用:

https://trends.google.com/trends/api/widgetdata/multiline/csv?req={"time":"2018-08-30 2019-08-30","resolution":"WEEK","locale":"de","comparisonItem":[{"geo":{},"complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"trump"}]}}],"requestOptions":{"property":"","backend":"IZG","category":0}}&token=APP6_UEAAAAAXWrEbGVLW-ssfeQvOJgr9938DRgYO1sm&tz=-120

我现在可以轻松地将此csv放入pandas数据框中。理想情况下,我现在只需操纵url即可发出自定义请求并加载新数据。我的问题是我不能使用相同的token参数,因为它是为每个单独的csv请求新生成的。我认为Origin of tokens in Google trends API call中的shaochuancs的答案描述了我所面临的问题。谁能解释我如何请求此令牌,然后将该令牌用于第二个请求(实际的csv下载)? :/

0 个答案:

没有答案