Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Perform Yahoo searches in 2 lines of code

By Peter Cooper / June 2, 2006

Step 1: Get the Yahoo-Ruby API. It's only a small Ruby file. Its only dependencies are net/http and REXML that come with Ruby anyway.

Step 2: Make sure you have a Yahoo! API ID. If you don't, get one now.

Step 3: Use a script like this one from O'Reilly's Yahoo! Hacks book. The code can be as simple as this:

obj = WebSearch.new('insert app ID', 'chunky bacon', 'phrase', 10)
results = obj.parse_results
# results now contains an array of hashes
puts results.inspect

Other Posts to Enjoy

Twitter Mentions