#!/usr/bin/ruby
require 'open-uri'
site = ARGV[0]
query = URI.escape(ARGV[1..-1].join(" "))
case site
when "google": url = "http://www.google.com/search?q=#{query}"
when "wikipedia": url = "http://en.wikipedia.org/wiki/Special\:Search?search=#{query}"
when "torrentz": url = "http://www.torrentz.com/search?q=#{query}"
when "isohunt": url = "http://isohunt.com/torrents/?ihq=#{query}"
when "mininova": url = "http://www.mininova.org/search/?search=#{query}"
end
system("elinks #{url}")
Monday, October 20, 2008
Better search script (ruby)
Turns out I can kick off a text based browser from Ruby just fine. The trick is to use sytem("elinks") instead of `elinks`. Here's the Ruby version of my search script (cleaner):
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment