Search code examples
ruby-on-railsrubygoogle-apigoogle-searchgoogle-search-api

How to retrieve top 10 Google search results from a keyword through an API in Ruby?


I'm a little confused as to what is the best way to retrieve the top 10 Google results for a specific search/keyword. I just need the title and url (description is not essential).

I'm using Ruby and apparently there was a great way to do it with the googleajax gem. I've been able to get it to work but am concerned that it's a deprecated API and could be phased out any day. Also, the workaround to get more than 4 results at a time isn't very clean.

I think the Google Custom Search might be an option but the daily limit of 100 queries is restricting. I would prefer to not scrape Google as it's a violation of their terms.

What other options do I have to make this work? Any json/ruby/rails option would work for me. Thank you!


Solution

  • You're not very explicit in your question about the trade offs you're willing to make, But you might want to think about this more:

    I think the Google Custom Search might be an option but the daily limit of 100 queries is restricting. I would prefer to not scrape Google as it's a violation of their terms.

    I've used google custom search, and it is very easy but the limit is in place. If you are concerned about not violating Google's TOS, this is the only way to go. You need to decide if you're willing to violate the TOS, and if not you should just use the google custom search.