Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google rate limit kicking in #42

Closed
mttkay opened this issue Feb 24, 2016 · 12 comments
Closed

Google rate limit kicking in #42

mttkay opened this issue Feb 24, 2016 · 12 comments

Comments

@mttkay
Copy link

mttkay commented Feb 24, 2016

While issuing a query, the app failed with the following error:

⭐  how2 -l android launch activity in new task                                                      
-You are doing too many requests to Google. You need to wait a bit before trying again.`

If the app is using an API key shared across all users, it might be hitting a rate limit earlier than expected?

@danyshaanan
Copy link
Contributor

I think that there isn't a shared API key. This might be caused by someone in your network running lots of google api calls. (This probably makes more sense if you are in an office rather than at home).

@vasergen
Copy link

Have the same problem, after playing few minutes I always got an error "You are doing too many requests to Google. You need to wait a bit before trying again"

@mkohlmyr
Copy link

  1. The how2 module does not use the Google Search API as it (to the best of my knowlege) has been deprecated in favour of Google Custom Search, which does not suit the needs of the project, not least of all because it imposes severe rate limits.
  2. The error actually stems from node-google, the dependency how2 uses for scraping google results, which (as it should) respects the rate limiting Google imposes on what it believes to be (correctly in this case) automated traffic. This appears to be in the neighbourhood of four queries per minute.
  3. A realistic (and useful!) fix for this issue would probably involve writing npm modules that implement the same interface as node-google (or a consistent adapter for existing modules) but for scraping bing and duck-duck-go. If searches were then scheduled round-robin from how2, it could perhaps triple the rate limit (depending on their respective limits). If there is sufficient interest in that solution, I'd be happy to take a look at it.

Hope that helps!

@nicandris
Copy link

I didn't even managed to use this once. I always get the rate limit msg

@santinic
Copy link
Owner

Yeah we need someone to write an api to scrape bing or duckduckgo

@mkohlmyr
Copy link

mkohlmyr commented Mar 1, 2016

I'm happy to take a look at implementing that in the coming week, if you'd like.

@santinic
Copy link
Owner

santinic commented Mar 1, 2016

@mkohlmyr awesome

@mkohlmyr
Copy link

mkohlmyr commented Mar 2, 2016

Pretty sure I have ddg / bing / google basically working with an -e flag for search engine selection. If it sounds interesting I could also add support for an environment variable to set the default.

Let me know if you want any changes to https://github.com/mkohlmyr/how2/commit/4b0cf93f9e87634f125d28c658a313a7e1517e23 before I make a PR. Forgot about the tests!

https://github.com/mkohlmyr/how2/commit/4b0cf93f9e87634f125d28c658a313a7e1517e23
+
https://github.com/mkohlmyr/how2/commit/db290793ddf01d2e6729b566a387d82445cf1f53

Let me know if you want any changes.

@mkohlmyr
Copy link

mkohlmyr commented Mar 7, 2016

Ping @santinic re commits above 📢

Happy to squash them if you feel that's cleaner, or if you want me to rename / restructure any of the changes.

@santinic
Copy link
Owner

santinic commented Mar 7, 2016

@mkohlmyr sorry for the delay. It looks really good ! I have two questions:

  • I seem to get fewer answers with google compared with the node-google, do you know why?
  • With bing, I get this:

|Cannot connect to search engine.
Error: Failed to locate valid search results on page for query: [object Object]```

But, it's amazing :) thanks for your work!

@mkohlmyr
Copy link

mkohlmyr commented Mar 9, 2016

  • You're right, I didn't include the num querystring parameter for the google URL. What number would you like? node-google sets a default of 10 and a max of 100 I believe.
  • I will take a look at that over the next few days, I did notice sometimes bing struggled to return answers for some queries.

I'll hit you back up by the end of the weekend probably with some updates.

@mkohlmyr
Copy link

So I have done some investigating.

Your error is probably a rate limiting page that I was unaware of. It would be easy to improve the printing of the parameters, I could also create a special error message for this case by looking at the source it brings back.

FWIW it also looks like Bing has a tendency to return questions that have been closed by the user, moderator or have no answers, all of which would cause the magic search to reply with "cannot find any reasonable answer for your query". e.g. how2 reverse proxy nginx -e bing.

I have not had time to implement the changes I mentioned, but I will hopefully get to it later this week (after wednesday). If you don't want to wait, feel free to adapt the code I posted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants