google-trends-api icon indicating copy to clipboard operation
google-trends-api copied to clipboard

Add trending searches method

Open tobihagemann opened this issue 7 years ago • 14 comments

Have you already thought about adding a "trending searches" method, like in the Python library you've linked? https://github.com/GeneralMills/pytrends#trending-searches

tobihagemann avatar Mar 20 '18 19:03 tobihagemann

That could be added! Looks like it would take a bit of configuration changing since it requires POST vs GET, but definitely doable

pat310 avatar Mar 21 '18 14:03 pat310

Hi there ...

I need the trending search methods and would love to use your framework to implement these apis for the missing search(es). Do you mind if I add/participate on your project, this would be the ideal place for the method(s)?

Please let me know. In the meanwhile I'll research what is necessary.

Regards,

Patrick JP Colibry Consulting

Colibry-Source avatar Nov 21 '18 19:11 Colibry-Source

@Colibry-Source That would be great. Would you be able to make PRs in?

pat310 avatar Nov 21 '18 21:11 pat310

Hi, sorry I don't understand what you mean by 'PRs'? Do you mean a pull Request?

Colibry-Source avatar Nov 23 '18 22:11 Colibry-Source

Yup, pull requests

pat310 avatar Dec 02 '18 17:12 pat310

@Colibry-Source It looks like the python trending searches uses this URL with a POST method: TRENDING_SEARCHES_URL = 'https://trends.google.com/trends/hottrends/hotItems'

Right now in utilities.js it's hard coded to always perform a GET so we would need to update this object to also take a method

pat310 avatar Dec 02 '18 18:12 pat310

@Colibry-Source I think we should look into the daily trends endpoint, it would probably be easier to implement and might cover what we're looking for.

It goes something like this: https://trends.google.com/trends/api/dailytrends?hl=en-US&tz=300&geo=US&ns=15

Let me know what you think.

pat310 avatar Dec 02 '18 18:12 pat310

There is also real time searches: https://trends.google.com/trends/api/realtimetrends?hl=en-US&tz=300&cat=all&fi=0&fs=0&geo=US&ri=300&rs=20&sort=0

pat310 avatar Dec 02 '18 18:12 pat310

Thanks for bringing this to my attention. I'll add it to the api also.

PJP

⁣Sent from BlueMail ​

On Dec 2, 2018, 13:34, at 13:34, Patrick Trasborg [email protected] wrote:

There is also real time searches: https://trends.google.com/trends/api/realtimetrends?hl=en-US&tz=300&cat=all&fi=0&fs=0&geo=US&ri=300&rs=20&sort=0

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/pat310/google-trends-api/issues/99#issuecomment-443531056

Colibry-Source avatar Dec 02 '18 22:12 Colibry-Source

Yes, this is exactly what I'm using to implement. It fits nicely with the framework you've created and as such I will avoid the extra work of implementing post logic. I did not find a reference to the POST method you talked about. I wanted to do some research to see if there was a difference in results. I'll be moving ahead with the GET solution in the meanwhile.

On Sun, Dec 2, 2018 at 1:29 PM Patrick Trasborg [email protected] wrote:

@Colibry-Source https://github.com/Colibry-Source I think we should look into the daily trends https://trends.google.com/trends/trendingsearches/daily?geo=US endpoint, it would probably be easier to implement and might cover what we're looking for.

It goes something like this:

https://trends.google.com/trends/api/dailytrends?hl=en-US&tz=300&geo=US&ns=15

Let me know what you think.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pat310/google-trends-api/issues/99#issuecomment-443530659, or mute the thread https://github.com/notifications/unsubscribe-auth/ApknalTaNj9lzxMyow2pICmdXsNPGgwBks5u1Bv1gaJpZM4Syjg7 .

Colibry-Source avatar Dec 03 '18 21:12 Colibry-Source

Hi Patrick,

Just a quick update. I was able to implement both in a way that seems to compliment the existing work. However, the returned data set for both queries are very verbose. I'll provide some more info in the documentation on how to use it. The real-time query search in particular will give around 8 results in detail, but will provide a list of 300 articles IDS that represent trending information. I have no found a way to use theses articles IDS to pull back more information if the 8 provided are not enough. Unfortunately, I don't have the time to research this further at the moment as I am behind in my own project that uses this information. I see somehow the official googletrends page is translating these to another ID and them doing a 'post' call to retrieve more information with a whole bunch of information sent that I have no idea how is gotten but I can confirm that the info passed isn't present in the result set that was provided by the initial google trend call. So there is a lookup "process" that is happening that I haven't been able to identify. Perhaps Ill look at the python version of these libraries (that seem to be broken also) to see what was done in the past.

The next steps, once i have some down time would be to update the tests, document and research more behavior about the needed parameters and then you can approve and merge it back into the project.

I'll update my own repository with the preliminary code and you can give it a look over.

Regards,

PJP

On Mon, Dec 3, 2018 at 4:12 PM Colibry Consulting < [email protected]> wrote:

Yes, this is exactly what I'm using to implement. It fits nicely with the framework you've created and as such I will avoid the extra work of implementing post logic. I did not find a reference to the POST method you talked about. I wanted to do some research to see if there was a difference in results. I'll be moving ahead with the GET solution in the meanwhile.

On Sun, Dec 2, 2018 at 1:29 PM Patrick Trasborg [email protected] wrote:

@Colibry-Source https://github.com/Colibry-Source I think we should look into the daily trends https://trends.google.com/trends/trendingsearches/daily?geo=US endpoint, it would probably be easier to implement and might cover what we're looking for.

It goes something like this:

https://trends.google.com/trends/api/dailytrends?hl=en-US&tz=300&geo=US&ns=15

Let me know what you think.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pat310/google-trends-api/issues/99#issuecomment-443530659, or mute the thread https://github.com/notifications/unsubscribe-auth/ApknalTaNj9lzxMyow2pICmdXsNPGgwBks5u1Bv1gaJpZM4Syjg7 .

Colibry-Source avatar Dec 29 '18 14:12 Colibry-Source

The proposed source changes can be found here:

https://github.com/Colibry-Source/new-google-trends-api

You'd need to run the build process script via npm , and then use the outputted library to test the newer apis.

No documentation for it yet but here is my entry code that you can run with:

googleTrends.realTimeTrends({ geo: 'US', category: 'all', }, function(err, results) { if (err) console.log('oh no error!', err); else console.log(results); });

googleTrends.dailyTrends({ trendDate: new Date('2018-12-15'), geo: 'US', }, function(err, results) { if (err) { console.log('oh no error!', err) }else{ console.log(results); } });


Tests updates to come later but feel free to add feedback.

Colibry-Source avatar Dec 30 '18 19:12 Colibry-Source

Sorry i thought it best to close the old pull request because I had to remerge with with your master and then add some additional code based on the changes that were added in version 4.8. I hope this makes it cleaner to look at the newer code overall.

Colibry-Source avatar Jan 31 '19 17:01 Colibry-Source

There is also real time searches: https://trends.google.com/trends/api/realtimetrends?hl=en-US&tz=300&cat=all&fi=0&fs=0&geo=US&ri=300&rs=20&sort=0

Thank you very much! I am just looking for this link!

HyperionZhou avatar Nov 17 '21 05:11 HyperionZhou