Created
March 22, 2012 15:48
-
-
Save sandys/2159137 to your computer and use it in GitHub Desktop.
Ruby script to talk to google custom search api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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