Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

wsdl the google API (search google with ruby) (See related posts)

sign up to get a key first

require 'soap/wsdlDriver'
$KCODE = "UTF8"
key = 'LVJnAm5QFHblahblahblah your key here'

#create driver
wsdl = "http://api.google.com/GoogleSearch.wsdl"
driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
query = "your query string here"
start = 0
max = 10
  
# see http://dev.ctor.org/soap4r/browser/trunk/sample/wsdl/googleSearch/wsdlDriver.rb
@results = driver.doGoogleSearch( key, query, start, max, true, "", true, 'lang_en', '','')
snippets = @results.resultElements.collect { |r| r.snippet } # you can get all kinds'a' info here
self.update_attribute(:html, snippets.join("\n")) # or whatever


Comments on this post

dirtyaffairs posts on Oct 23, 2005 at 10:31
I tried to write a simple JSP to do this and it works very fine but I think that you have only 1000 queries per day.
peter posts on Oct 23, 2005 at 13:49
Yeah, 1000 queries a day is still the case, I believe.

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts