Ruby API for Yahoo Search Web Services

Discussion in 'Ruby' started by Premshree Pillai, Mar 1, 2005.

  1. Premshree Pillai, Mar 1, 2005
    #1
    1. Advertisements

  2. Premshree Pillai

    Paul Duncan Guest

    --sL7C0a98p/u5aVah
    Content-Type: text/plain; charset=us-ascii
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    Damn, you beat me to it :).
    --=20
    Paul Duncan <> pabs in #ruby-lang (OPN IRC)
    http://www.pablotron.org/ OpenPGP Key ID: 0x82C29562

    --sL7C0a98p/u5aVah
    Content-Type: application/pgp-signature; name="signature.asc"
    Content-Description: Digital signature
    Content-Disposition: inline

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.0 (GNU/Linux)

    iD8DBQFCJS50zdlT34LClWIRAiitAKCeLBbhj/UBfEdsPtK+svI7B1y8owCePH5J
    lfw7+6KbpaRqnCkOqhiXHSg=
    =KBP3
    -----END PGP SIGNATURE-----

    --sL7C0a98p/u5aVah--
     
    Paul Duncan, Mar 2, 2005
    #2
    1. Advertisements

  3. --------------enigC475878EB6B9AB919F66AFA8
    Content-Type: text/plain; charset=ISO-8859-1; format=flowed
    Content-Transfer-Encoding: 7bit

    Hi,

    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--
     
    NAKAMURA, Hiroshi, Mar 2, 2005
    #3
  4. :) Well, maybe you could come up with a neat one.
     
    Premshree Pillai, Mar 2, 2005
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.