Skip to content

Instantly share code, notes, and snippets.

@bomberstudios
Created November 11, 2008 12:38
Show Gist options
  • Save bomberstudios/23821 to your computer and use it in GitHub Desktop.
Save bomberstudios/23821 to your computer and use it in GitHub Desktop.
# RAE
require "rubygems"
require "curb"
require "hpricot"
def url_for word
"http://buscon.rae.es/draeI/SrvltGUIBusUsual?LEMA=#{word}&origen=RAE&TIPO_BUS=3"
end
def get_definition_for(word)
puts word
c = Curl::Easy.perform(url_for(word))
doc = Hpricot(c.body_str)
(doc/"span.eAcep").map { |i| i.inner_html }.select { |i| !(i =~ /<a/) }.each_with_index do |w,i|
puts "#{i+1}. #{w}"
end
end
get_definition_for "rubí"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment