Skip to content

Instantly share code, notes, and snippets.

@begriffs
Created March 15, 2012 13:48
Show Gist options
  • Save begriffs/2044285 to your computer and use it in GitHub Desktop.
Save begriffs/2044285 to your computer and use it in GitHub Desktop.
Learn word etymologies quickly from the command line
#!/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