pat310 / google-trends-api

An API layer on top of google trends
https://www.npmjs.com/package/google-trends-api
MIT License
877 stars 175 forks source link

more than 5 keywords #119

Open awb99 opened 5 years ago

awb99 commented 5 years ago

I tested running trend data on multiple keywords. When using more than 5 keywords, this is what comes back. It might be that google trend api has this hard limit, but it seems pretty low to me. This is the error that comes back when using 6 or more keywords:

'<!DOCTYPE html><html lang=en><meta charset=utf-8><meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"><title>Error 400 (Not Found)!!1</title><style nonce="tonQwK2Z/KRfQV8lxpc7Qw">*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{color:#222;text-align:unset;margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px;}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}pre{white-space:pre-wrap;}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}</style><div id="af-error-container"><a href=//www.google.com><span id=logo aria-label=Google></span></a><p><b>400.</b> <ins>That’s an error.</ins><p>The requested URL was not found on this server. <ins>That’s all we know.</ins></div>' }
hayksaakian commented 5 years ago

this is a limitation of Google's API rather than this library that you're using to access the API.

pat310 commented 5 years ago

Thanks @hayksaakian! Not sure if there is a good way to communicate this issue. One possible solution is to actually put a hard limit on the array size, but then this may change whenever Google Trends changes. We could add a guide in the documentation saying that Google Trends only accepts up to 5 keywords and then update it anytime they change it, but I feel like people would miss that.

awb99 commented 5 years ago

Thabks for the explanations! To me this limit dramatically uses the usefullness of google trends. The reason is that it normalises all keywords so that 100 equals to the highest # of searches of all searches. So if I want to conpare say 6 keywords then I have to include the 100 ranked keyword in the second query with the 6th keyword, because otherwise they would be normalises differently. If google would give the raw data then one could do the normalisation one self easily. I guess that's life. Haha

On Sat, 6 Apr 2019, 14:43 Patrick Trasborg, notifications@github.com wrote:

Thanks @hayksaakian https://github.com/hayksaakian! Not sure if there is a good way to communicate this issue. One possible solution is to actually put a hard limit on the array size, but then this may change whenever Google Trends changes. We could add a guide in the documentation saying that Google Trends only accepts up to 5 keywords and then update it anytime they change it, but I feel like people would miss that.

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

JMdoubleU commented 5 years ago

@awb99 Including a control keyword in all requests might be a way around that.