YahooSearchApi Version 0.0.6 ============== Version 0.0.6 - 2007/04/15 - Added YahooSearchApi::AssistSearchService. It can access to Yahoo Assist Word Search. Version 0.0.5 - 2007/04/15 - Added YahooSearchApi::VideoSearchService. It can access to Yahoo Video Search. Version 0.0.4 - 2007/04/14 - Added YahooSearchApi::ImageSearchService. It can access to Yahoo Image Search. Version 0.0.3 - 2007/04/12 - Fix bug in Sample Usage of Readme. - Add module name to classes called in YahooSearchApi::WebSearchService. Version 0.0.2 - 2007/04/10 - Method "results" is added. This is recommended more than "get_results". Version 0.0.1 - 2007/04/09 by Junya Ishihara == Overview This plugin is a library to use Yahoo Search API on Ruby on Rails. == Installing Run script/plugin install http://rails-workshop-tokyo.googlecode.com/svn/trunk/plugins/yahoo_search_api or checkout the source into your plugins folder. svn checkout http://rails-workshop-tokyo.googlecode.com/svn/trunk/plugins/yahoo_search_api == Example Usage === Controller(yahoo_controller.rb) class YahooController < ApplicationController def search # For detail of parameters, please see # http://developer.yahoo.co.jp/search/web/V1/webSearch.html search_params = { :type => 'all', :results => 10, :start => 1, :adult_ok => nil, :similar_ok => nil, :language => 'ja', :country => nil, :site => {'www.yahoo.co.jp', 'www.asahi.com'} } web_search_service = YahooSearchApi::WebSearchService.new( 'Your Yahoo Application ID', 'Search Keyword', search_params ) # Get search results @results = web_search_service.results # Get request URL @req_url = web_search_service.req_url end def image_search # For detail of parameters, please see # http://developer.yahoo.co.jp/search/image/V1/imageSearch.html search_params = { :type => 'all', :results => 10, :start => 1, :format => 'any', :adult_ok => nil, :coloration => 'any', :site => {'www.yahoo.co.jp', 'www.asahi.com'} } image_search_service = YahooSearchApi::ImageSearchService.new( 'Your Yahoo Application ID', 'Search Keyword', search_params ) # Get search results @results = image_search_service.results # Get request URL @req_url = image_search_service.req_url end def video_search # For detail of parameters, please see # http://developer.yahoo.co.jp/search/video/V1/videoSearch.html search_params = { :type => 'all', :results => 10, :start => 1, :format => 'any', :adult_ok => nil, :site => {'www.yahoo.co.jp', 'www.asahi.com'} } video_search_service = YahooSearchApi::VideoSearchService.new( 'Your Yahoo Application ID', 'Search Keyword', search_params ) # Get search results @results = video_search_service.results # Get request URL @req_url = video_search_service.req_url end def assist_search # For detail of parameters, please see # http://developer.yahoo.co.jp/search/webunit/V1/webunitSearch.html search_params = { :results => 10, :start => 1, } assist_search_service = YahooSearchApi::AssistSearchService.new( 'Your Yahoo Application ID', 'Search Keyword', search_params ) # Get search results @results = assist_search_service.results # Get request URL @req_url = assist_search_service.req_url end end === View(search.rhtml)

Yahoo#search

Request URL: <%= @req_url %>

<%- unless @results.is_a?(Array) -%> Error: <%= @results %> <%- else -%> <%- @results.each do |result| -%>

<%= link_to result.Title, result.ClickUrl %>
<%= result.Summary %>
<%= result.Url %> - <%= Time.at(result.ModificationDate.to_i).strftime("%d %b %Y")%>

<%- end -%> <%- end -%> === View(image_search.rhtml)

Yahoo#image_search

Request URL: <%= @req_url %>

<%- unless @results.is_a?(Array) -%> Error: <%= @results %> <%- else -%> <%- @results.each do |result| -%>

Title: <%= result.Title %>
Summary: <%= result.Summary %>

Image Url: <%= link_to result.Url, result.ClickUrl %>
Referer: <%= link_to result.RefererUrl, result.RefererUrl %>
FileSize: <%= result.FileSize %>
FileFormat: <%= result.FileFormat %>
Height: <%= result.Height %>
Width: <%= result.Width %>
Publisher: <%= result.Publisher %>
Restrictions: <%= result.Restrictions %>
Copyright: <%= result.Copyright %>


<%- end -%> <%- end -%> === View(video_search.rhtml)

Yahoo#video_search

Request URL: <%= @req_url %>

<%- unless @results.is_a?(Array) -%> Error: <%= @results %> <%- else -%> <%- @results.each do |result| -%>

Title: <%= result.Title %>
Summary: <%= result.Summary %>

Image Url: <%= link_to result.Url, result.ClickUrl %>
Referer: <%= link_to result.RefererUrl, result.RefererUrl %>
FileSize: <%= result.FileSize %>
FileFormat: <%= result.FileFormat %>
Height: <%= result.Height %>
Width: <%= result.Width %>
Duration: <%= result.Duration %>
Channels: <%= result.Channels %>
Streaming: <%= result.Streaming %>
Publisher: <%= result.Publisher %>
Restrictions: <%= result.Restrictions %>
Copyright: <%= result.Copyright %>


<%- end -%> <%- end -%> === View(assist_search.rhtml)

Yahoo#assist_search

Request URL: <%= @req_url %>

<%- unless @results.is_a?(Array) -%> Error: <%= @results %> <%- else -%> <%- @results.each do |result| -%> <%= result %>
<%- end -%> <%- end -%> == Documentation You can create the documentation by running: rake rdoc == Required files open-uri rexml/document cgi == Links Yahoo! JAPAN DEVELOPER NETWORK http://developer.yahoo.co.jp/search/ == License This plugin is released under the MIT license. See MIT-LICENSE for details. == Feedback Please leave a comment or send a trackback to http://blog.champierre.com/archives/504