www.SmarteGuru.com
  Home | Blogs | Recipe | Find a Friend | Discussion Board | Resources | Developers Area | Articles | Health |  Login | Register Now 

BOSSMan: Yahoo BOSS gem

Yahoo BOSS is an API that allows for use of search results from Yahoo’s search index.

Under the surface though, Yahoo has removed the 5,000 query per day limit, you’re unrestricted in how you present the data returned, you can re-order the data, and no attribution is required.

For Rubyists ready to play with BOSS, Jay Pignata has developed BOSSMan, a library for interacting with the Yahoo! BOSS Web service. I’ve put together quick gem for handling interaction with it.

Installation:

$ gem sources -a http://gems.github.com
$ gem install jpignata-bossman

Sample code:

require ‘rubygems’
require ‘bossman’
include BOSSMan
BOSSMan.application_id = “Your Application ID here”
news = BOSSMan::Search.news(”Ruby on rails”, 0, 50)
news.results.each do |result|
puts “#{result.title} [from #{result.source}]”
puts “-” * 80
puts “#{result.abstract}”
puts
end

Output:
$ ruby ror.rb
Application Development Aptana Mixes AJAX, Python with Pydev IDE Buy [from
eWeek]
———————————————————-
Aptana Studio eases Web development, deployment and management by integrating AJAX tooling with PHP, Ruby on Rails, Aptana’s Jaxer AJAX server and now …

Aptana Swallows Python [from Private Equity Hub]
———————————————————-
Aptana Studio eases Web development, deployment and management by integrating best-in-class Ajax tooling with PHP, Ruby on Rails, Jaxer, and now imminently, …

Free app testing set for Ruby on Rails [from InfoWorld]
———————————————————-
By Paul Krill FiveRuns and Morph Labs on Tuesday will announce they are partnering to provide free application performance testing for Ruby on Rails …

………….
………….
………….

The 50 is the number of results that you want back. I do not store the search results or do any pagination in this example.

Lastly you’ll want to code up your views. Here is a sample of my results view and my search form:

Search Form:

<% form_tag :action => “search_results” do %>
<%= label :search_form, :find %>:
<%= text_field :search_form, :find %>
<%= submit_tag ‘Search’ %>
<% end %>

Results View:

<% if @search.count.to_i > 0 %>
<% @search.results.each do |result| %>
<%= link_to result.title, result.url %>
<%= result.abstract %>
<% end %>
<% else %>
No results found
<% end %>

BOSSMan supports Web, news, and image searches out of the box. You can dump to JSON, XML, or YAML and access all of the relevant attributes through methods. great!

Related Posts

Tags: , , , , , , ,


Viewed: 127 views

Leave a Reply

Comment moderation is enabled. Your comment may take some time to appear.

Home - About Us - Help - Terms and Conditions - Site Map - Link to Us - Resources - Contact Us
Google Rank Calculator | Suggest developer resource | Suggest Article
All rights reserved © 2007 SmarteGuru.com.