Skip to content

Instantly share code, notes, and snippets.

@davetoxa
Last active April 8, 2017 11:46
Show Gist options
  • Save davetoxa/7153dcff0c7d626a48a62fd3b1edc6f1 to your computer and use it in GitHub Desktop.
Save davetoxa/7153dcff0c7d626a48a62fd3b1edc6f1 to your computer and use it in GitHub Desktop.
mkdev: seeds.rb и Nokogiri
require "nokogiri"
require "open-uri"
url = 'http://1000mostcommonwords.com/1000-most-common-german-words/'
doc = Nokogiri::HTML(open url)
doc.css('tr').each do |tr|
original_text = tr.css('td:nth-child(2)').text
translated_text = tr.css('td:nth-child(3)').text
puts "#{original_text}: #{translated_text}"
# Card.create(
# original_text: original_text,
# translated_text: translated_text,
# review_date: 3.days.from_now
# )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment