Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/trunk/sample/wsdl/googleSearch/wsdlDriver.rb

Revision 1605, 0.7 kB (checked in by nahi, 5 years ago)

updated deprecated method usage. closes #138.

  • Property svn:eol-style set to native
  • Property svn:keywords set to author date id revision
Line 
1 #require 'uconv'
2 require 'soap/wsdlDriver'
3
4 word = ARGV.shift
5 # You must get key from http://www.google.com/apis/ to use Google Web APIs.
6 key = File.open(File.expand_path("~/.google_key")) { |f| f.read }.chomp
7
8 GOOGLE_WSDL = 'http://api.google.com/GoogleSearch.wsdl'
9 # GOOGLE_WSDL = 'GoogleSearch.wsdl'
10
11 def html2rd(str)
12   str.gsub(%r(<b>(.*?)</b>), '((*\\1*))').strip
13 end
14
15
16 google = SOAP::WSDLDriverFactory.new(GOOGLE_WSDL).create_rpc_driver
17 google.wiredump_dev = STDOUT if $DEBUG
18 google.mandatorycharset = 'utf-8'
19 result = google.doGoogleSearch( key, word, 0, 10, false, "", false, "", 'utf-8', 'utf-8' )
20 result.resultElements.each do |ele|
21   puts "== #{html2rd(ele.title)}: #{ele["URL"]}"
22   puts html2rd(ele.snippet)
23   puts
24 end
Note: See TracBrowser for help on using the browser.