I am using rails 2.3. My requirement is to get the top 20 links from Google search of a query.
I want to use the http://rubygems.org/gems/google-api-client gem.
But I am not able to find any proper documentation for doing custom google search with authentication. Can any one point me to an example, from where I can understand how to use the google-api-client gem for custom google search?
If anyone stumble on this, this is an updated version of this code:
Gemfile
gem 'google-api-client', '~> 0.11'
search.rb
require 'google/apis/customsearch_v1'
Search = Google::Apis::CustomsearchV1
search_client = Search::CustomsearchService.new
search_client.key = 'YOUR API KEY'
response = search_client.list_cses('your query', {cx: 'Search Engine ID'})
status, headers, body = response
pp status
pp headers
pp body
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With