Skip to content

Instantly share code, notes, and snippets.

@waynegraham
Created October 27, 2010 17:01
Show Gist options
  • Save waynegraham/649456 to your computer and use it in GitHub Desktop.
Save waynegraham/649456 to your computer and use it in GitHub Desktop.
require 'open3'
require 'open-uri'
require 'rubygems'
require 'nokogiri'
search = 'rocket science'
results = open "http://search.lib.virginia.edu/catalog?q=#{URI.escape(search)}&per_page=2"
Open3.popen3('say -v Vicki') do |stdin, stdout, stderr|
stdin << "Virgo results for #{search}..."
Nokogiri::XML(results).search('.document').each_with_index do |d,i|
stdin << "Item #{i+1},"
stdin << "Catalog key, #{d['id'].gsub(/^Doc/,'')},"
stdin << "Title, #{d.at('.titleField a').text},"
end
stdin.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment