Skip to content

Instantly share code, notes, and snippets.

@atamis
Created April 12, 2012 07:40
Show Gist options
  • Save atamis/2365472 to your computer and use it in GitHub Desktop.
Save atamis/2365472 to your computer and use it in GitHub Desktop.
William Whitaker's Words script
#!/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