Using: Rails 3.1.1
I am using the googleajax gem to perform Google-searches in a script with severals of thousands searches.
After some 20 searches or so, I need to have a rescue that waits and retries since it seems like you cannot perform more than a certain amount of searches in a row. After approximately one minute the retry makes the search continue for 10 more searches. The result is that it takes about one minute to perform 10 searches, which makes the script incredibly slow.
It seems likely that Google has a block in the amount of searches one can perform (based on ip? based on googleajax referrer?) but is there a way around it?
What can I do to be able to perform Google searches through the googleajax gem without having to pause and wait all the time? What alternatives do I have?
The code (with unimportant parts cut out):
begin
puts "Searching with " + gsquery
results = GoogleAjax::Search.web(gsquery)[:results]
if results.count > 0
puts "#{results.count} results found for #{page.name}. Registering the connection!"
end
rescue
puts "Try again in 3 sec"
sleep 3
retry
rescue Timeout::Error
puts "Timeout Error, sleep 15 sec"
sleep 15
retry
end