Created
April 12, 2012 07:40
-
-
Save atamis/2365472 to your computer and use it in GitHub Desktop.
William Whitaker's Words script
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 'nokogiri' | |
require 'open-uri' | |
def url(x) | |
"http://www.archives.nd.edu/cgi-bin/wordz.pl?keyword=" + x | |
end | |
def get(url) | |
open(url) | |
end | |
def parse(resp) | |
Nokogiri::HTML(resp).css("pre").map do |text| | |
text.content.split("\n\n") | |
end | |
end | |
def all(word) | |
parse(get(url(word))) | |
end | |
ARGV.each do |word| | |
puts parse(get(url(word))).inspect | |
end | |
x = "" | |
while x = gets | |
puts all(x) | |
puts "="*80 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment