GeneralMills / pytrends

Pseudo API for Google Trends
Other
3.2k stars 813 forks source link

how to get history of hourly google trends? #108

Closed randomgambit closed 7 years ago

randomgambit commented 7 years ago

Hi,

Amazing Api!

I was wondering whether one can use your package to get historical hourly counts for google trends related to a particular keyword?

is that even possible?

Thanks!

dreyco676 commented 7 years ago

Yes you can however the hourly data is limited to 24hrs at a time. Since its 100 indexed data if you wanted more than a day of hourly you'd have to window your requests with overlap and do some math to reindex subsequent pulls of data.

Let me know if that makes any sense.

Also great choice of avatar, best character in the game.

randomgambit commented 7 years ago

@dreyco676 yes the 100 index data is tricky. Is it even possible to get back the original ranking across different days?

dreyco676 commented 7 years ago

Should be. You may end up with values over 100 for subsequent days. You will also have to chain from your starting point.

Day 1 your highest point is 100 at 3pm and let's say its 86 at 12am. Which means the search volume is 86% of the 3pm number.

If you pull the next days data the 100 point is maybe at 4pm and the overlap point is 76. Now you have an equation 76x = 86. Solving for x you have ~1.1315 as the conversion rate for day 2 values.

Then you have to repeat this operation for each additional day.

dreyco676 commented 7 years ago

Looks like this solves your problem. Closing.

ds501 commented 7 years ago

Hi, I just wanted to expand on this question. I know that I can pull hourly data from the past 24 hours, however, I am not sure if it's possible to get historical hourly data prior to that. For example, if I wanted hourly data between the dates of 07/06/16 00:00:00 UTC and 07/07/16 00:00:00 UTC, is it possible to pull it? Thanks so much.

Snowcrash5 commented 7 years ago

I found that when doing a time range that includes the time as Thr, for example "2017-02-06T3 2017-02-12T5" it shows every hour's value

randomgambit commented 7 years ago

@Snowcrash5 what is the maximum time span you can pull this way?

Snowcrash5 commented 7 years ago

@randomgambit you can pull around 1 week per query, so you gotta use a bunch of queries with each query overlapping some of the next, to find the proportions between the queries.

LRonHubs commented 6 years ago

https://github.com/clintonboys/trendy-scraper appears to do something similar with day-by-day data.

Anyone willing to share some code / push to a repo?

cwazuidema commented 6 years ago

@Snowcrash5 "I found that when doing a time range that includes the time as Thr, for example "2017-02-06T3 2017-02-12T5" it shows every hour's value"

Thank you so much buddy!!!! Exactly what I was looking for!

BastianF commented 5 years ago

With this code you will be able to get historical hourly gTrends data: (https://github.com/BastianF/Hourly-historical-Google-Trends-Data/blob/master/Hourly%20historical%20Google%20Trends%20Data.ipynb)

davins90 commented 1 year ago

Hi guys,

a question: if I want to download hourly data for 4 weeks for a specific keyword, do I need to rescale with the "ratio-trick" every week to avoid the problem that hourly data are limited to a 7 days period?

Thanks

NicolasCaronPro commented 1 year ago

@davins90 Hi, yes you have to apply the operations to every week to get the hourly over 4 weeks @BastianF Thank you for your code, it was a real good aid :) I have a issue, what can I do if the inerest of the last our of the week i or the first hour of week i+1 are equal to 0 ? Do you thing that there is any change that I can fit a regression problem to avoid 0 value ?

Thanks