-
-
Save begriffs/2694527 to your computer and use it in GitHub Desktop.
Etymology Lookup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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