Hacked one. See http://www.livejournal.com/users/premshree/56199.html
Not very elegant and all. Prolly someone else could come up with
something nice.
--
Premshree Pillai
http://www.livejournal.com/users/premshree/
Damn, you beat me to it :).
> Hacked one. See http://www.livejournal.com/users/premshree/56199.html
>
> Not very elegant and all. Prolly someone else could come up with
> something nice.
>
> --
> Premshree Pillai
> http://www.livejournal.com/users/premshree/
--
Paul Duncan <pa...@pablotron.org> pabs in #ruby-lang (OPN IRC)
http://www.pablotron.org/ OpenPGP Key ID: 0x82C29562
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
:-) Well, maybe you could come up with a neat one.