PyTrends历史小时数据

时间:2019-01-08 22:17:26

标签: google-trends

我是Python和编码方面的新手。谢谢您的耐心等候。

使用PyTrends,我试图获取一个全年的单个搜索字词的Google趋势每小时结果。我看到Python软件基金会(https://pypi.org/project/pytrends/)声明了“'现在是1-H'“”“似乎只能工作1、4小时”。我已经尝试了一些尝试获取自定义小时搜索的示例,但没有一个适合我。我想知道是否不再可能获取Google趋势历史小时数据,而我应该停止寻找吗?

1 个答案:

答案 0 :(得分:0)

也许已经有点晚了,但是如果将来有人发现这个问题,您可以在PyTrends开发人员的github上找到如何获取每小时的Google趋势历史数据的最新方法:

https://github.com/GeneralMills/pytrends#historical-hourly-interest

应用了相应功能的简短代码段

# Since pytrends is returning a DataFrame object, we need pandas:
import pandas as pd
# Import of pytrends (needs to be pip installed first):
from pytrends.request import TrendReq

pytrends = TrendReq(hl='en-US', tz=360)
kw_list = ['search_term_1', 'search_term_2']

search_df = pytrends.get_historical_interest(kw_list, year_start=2019,
                                             month_start=5, day_start=1,
                                             hour_start=0, year_end=2019,
                                             month_end=7, day_end=31, hour_end=0,
                                             cat=0, geo='', gprop='', sleep=60)

将各个参数替换为所需的参数,然后即可进行操作-每小时的历史Google趋势数据。

希望它有所帮助! 最好, yawicz

相关问题