Joe Foley
Joe Foley

Reputation: 21

PyTrends Historical Hourly Data

I am new to Python and coding in general. Thank you for your patience.

Using PyTrends I am trying to get hourly results for Google Trends for a single search term for an entire year . I see that the Python Software foundation (https://pypi.org/project/pytrends/ )states"'now 1-H' " "Seems to only work for 1, 4 hours only" . I have tried some examples of people trying to get custom hourly searches but none work for me. I am wondering is it no longer possible to get Google Trends historical hourly data and I should just stop looking?

Upvotes: 2

Views: 4738

Answers (1)

yawicz
yawicz

Reputation: 41

Maybe a little bit late already, but in case anybody finds this question in the future, you can find the most recent way of how to get historical hourly Google Trends data on the github of the PyTrends developer:

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

A short snippet with the respective function applied:

# 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)

Replace the respective parameters with the desired ones and there you go - hourly historical Google Trends data.

Hope it helped! Best, yawicz

Upvotes: 4

Related Questions