Skip to content

Instantly share code, notes, and snippets.

@sandys
Created March 22, 2012 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandys/2159137 to your computer and use it in GitHub Desktop.
Save sandys/2159137 to your computer and use it in GitHub Desktop.
Ruby script to talk to google custom search api
require 'google/api_client'
client = Google::APIClient.new(:key => 'something')
client.authorization = nil
search = client.discovered_api('customsearch')
offset = 100
1.step(10,10) do |i|
#cx is gotten from the API registration page
response = client.execute(search.cse.list, 'q' => "inurl:seller", 'cx' => '000236314787215291185:hoaiqgvjsxw', 'startIndex' => offset.to_s )
#puts response.body
r = JSON.parse(response.body)
puts r
#puts (i + offset).to_s
=begin
r["items"].each do |row|
puts row["title"]
end
=end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment