From: "NAKAMURA, Hiroshi" Date: 2005-03-02T16:42:34+09:00 Subject: Re: Ruby API for Yahoo Search Web Services --------------enigC475878EB6B9AB919F66AFA8 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, Premshree Pillai wrote: > So everybody knows about Yahoo's Search Web Services. Downloaded the > stuff... no Ruby API. > > Hacked one. See http://www.livejournal.com/users/premshree/56199.html And here's mine. Only an example for proof of concept. query = ARGV.shift or raise ArgumentError require 'soap/marshal' class MyXMLHandler < SOAP::EncodingStyle::SOAPHandler Namespace = 'urn:myxmlhandler' add_handler def decode_parent(parent, node) super if parent.node # ignore absence of SOAP envelop things. end end require 'http-access2' url = 'http://api.search.yahoo.com/NewsSearchService/V1/newsSearch' param = { 'appid' => '!!! set_your_appid_here !!!', 'query' => query, 'results' => 3, 'language' => 'en', 'results_sort' => 'rank' } result = HTTPAccess2.get_content(url, param) opt = {:default_encodingstyle => 'urn:myxmlhandler'} soap = SOAP::Processor.unmarshal(result, opt) SOAP::Mapping.soap2obj(soap).Result.each do |result| next unless result["Thumbnail"] p result.Thumbnail.Url end Regards, // NaHi --------------enigC475878EB6B9AB919F66AFA8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCJW5df6b33ts2dPkRArJuAJoDViTNH375JUl7ghwPgwctbAfrCQCgmSGH cuLKshrewH+v3wykfnjEoaE= =6meR -----END PGP SIGNATURE----- --------------enigC475878EB6B9AB919F66AFA8--