[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Google API, Soap and windows XP

RubyTalk@gmail.com

5/17/2005 1:11:00 PM

Hello,I am playing with the google api and soap. I have the newest versionof soap and i think ruby 1.8. I created my code on a laptop withmandrake 10.2 with the same version of ruby and soap. On my laptop itworks fine. On my windows computer it give me an error."F:\Documents and Settings\iv\Desktop\googlerip>ruby googled.rbmonkey filetype:pdfLoading compatibility library...c:/ruby/lib/ruby/1.8/xsd/datatypes.rb:172:in `_set': {http://www.w3.org/2001...}string: cannot accept '<b>...</b> Tibetan year of the <b>monkey</b>. These instructions are traditionally given <b>...</b><br> thus will give the rare GÇÖ<b>Monkey</b>-Year-TeachingsGÇÖ after the inauguration in <b>...</b>'. (XSD::ValueSpaceError) from c:/ruby/lib/ruby/1.8/xsd/datatypes.rb:114:in `set' from c:/ruby/lib/ruby/1.8/soap/encodingstyle/soapHandler.rb:453:in `decode_textbuf' from c:/ruby/lib/ruby/1.8/soap/encodingstyle/soapHandler.rb:214:in `decode_tag_end' from c:/ruby/lib/ruby/1.8/soap/parser.rb:185:in `decode_tag_end' from c:/ruby/lib/ruby/1.8/soap/parser.rb:146:in `end_element' from c:/ruby/lib/ruby/1.8/xsd/xmlparser/parser.rb:75:in `end_element' from c:/ruby/lib/ruby/1.8/xsd/xmlparser/xmlparser.rb:36:in `do_parse' from c:/ruby/lib/ruby/1.8/xsd/xmlparser/xmlparser.rb:31:in `parse' ... 7 levels... from (eval):2:in `doGoogleSearch' from googled.rb:16 from googled.rb:15:in `each' from googled.rb:15"I am working off an example i found on the internet. Here is my code: require "soap/driver" ENDPOINT = 'http://api.google.com/search/... NS = 'urn:GoogleSearch' KEY = "Enter_your_Key" fail "Missing query args" if ARGV.empty? query = ARGV.join(" ") soap = SOAP::Driver.new(nil, nil, NS, ENDPOINT) soap.addMethodWithSOAPAction( 'doGoogleSearch', NS, 'key', 'q', 'start', 'maxResults', 'filter', 'restrict', 'safeSearch', 'lr', 'ie', 'oe') i=0for i in 0..90 res = soap.doGoogleSearch( KEY, query, i, 10, false, nil, false, nil, 'latin1', 'latin1') puts "Estimated result count: " + res.estimatedTotalResultsCount puts "Searched in:" + res.searchTime + " seconds" puts "Index start:" + res.startIndex puts "Index End:" + res.endIndex res.resultElements.each do |entry| puts puts entry.URL puts filename=entry.URL.gsub("//", '').gsub("~", '').gsub("/", '') if(!(FileTest.exist?(filename))) then aFile = File.new(filename, "w+") aFile.puts Net::HTTP.get(URI.parse(entry.URL)) puts entry.snippet end end i=i+9endAm i missing something on my windows computer? Becker
1 Answer

NAKAMURA, Hiroshi

5/29/2005 2:11:00 PM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Sorry for late reply.

ruby talk wrote:
> I am playing with the google api and soap. I have the newest version
> of soap and i think ruby 1.8. I created my code on a laptop with
> mandrake 10.2 with the same version of ruby and soap. On my laptop it
> works fine. On my windows computer it give me an error.
> "F:\Documents and Settings\iv\Desktop\googlerip>ruby googled.rb
> monkey filetype:
> pdf
> Loading compatibility library...
> c:/ruby/lib/ruby/1.8/xsd/datatypes.rb:172:in `_set': {http://www.w3.or...
> Schema}string: cannot accept '<b>...</b> Tibetan year of the <b>monkey</b>. Thes
> e instructions are traditionally given <b>...</b><br> thus will give the rare ?
> ÇÖ<b>Monkey</b>-Year-Teachings?ÇÖ after the inauguration in <b>...</b>'. (XSD::V
> alueSpaceError)

Hmm. Would you please tell me what will be happened if you run your
client with $KCODE = 'UTF8' ? Please do one of this.

1. run ruby interpreter with -Ku option (ruby -Ku googled.rb)
2. add '$KCODE = "UTF8"' line at the head of googled.rb

Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)

iD8DBQFCmc1Cf6b33ts2dPkRAii3AJ9Rwu134H5sL34cOo6OnCZEsrSG/QCfY+q3
i3+coJz5X0UCWsmjblUSYKc=
=OZVr
-----END PGP SIGNATURE-----