Class: TopTen::Scraper
- Inherits:
-
Object
- Object
- TopTen::Scraper
- Defined in:
- lib/top_ten/scraper.rb
Class Method Summary collapse
Class Method Details
.scrape_country ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/top_ten/scraper.rb', line 3 def self.scrape_country doc = Nokogiri::HTML(open("https://www.lonelyplanet.com/best-in-travel/countries")) countries = doc.css(".marketing-article") countries.collect do |country| new_country = TopTen::Top.new new_country.name = country.css("h1").text new_country.description = country.css(".marketing-article__content").text.strip new_country.save end end |