Created
February 4, 2010 14:24
-
-
Save tonini/294667 to your computer and use it in GitHub Desktop.
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
require 'uri' | |
require 'open-uri' | |
require 'nokogiri' | |
@from = "en" | |
@to = "de" | |
@word_to_translate = "accomplish" | |
@url = "http://www.google.ch/dictionary?source=translation&hl=en&q=##{@word_to_translate}&langpair=#{@from}|#{@to}" | |
doc = Nokogiri::HTML(open(URI.escape(@url))) | |
doc.css('li.dct-em span.dct-tt').each do |node| | |
puts node.text | |
end | |
# output: | |
# schaffen | |
# vollbringen | |
# vollenden | |
# leisten | |
# durchführen | |
# erreichen | |
# durchsetzen | |
# erzielen | |
# quantic notation | |
puts doc.css('div.dct-srch-rslt span.dct-tp').text.split(' ')[0] # [ə’kɒmplɪʃ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment