Skip to content

Instantly share code, notes, and snippets.

@begriffs
Created May 14, 2012 15:15
Show Gist options
  • Save begriffs/2694527 to your computer and use it in GitHub Desktop.
Save begriffs/2694527 to your computer and use it in GitHub Desktop.
Etymology Lookup
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'colorful'
url = "http://www.etymonline.com/index.php?search=#{ARGV[0]}"
doc = Nokogiri::HTML(open(url))
doc.css('dl').search('dt').each do |node|
puts "#{node.text}".white
desc = node.next_element.text
desc = (desc.scan(/.{,80}[^"\w]/).map { |line| line.strip }).join "\n"
puts "#{desc}".green
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment