Sha256: c5f4b381d87d3959879dfe6ce5e6ec733d0ea24cbb46e0ecb5ba1a0cd6bd6dd8

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

require 'open-uri'
require 'pry'
class Destinations::TravelDestinationsLists

  def self.scrape_list
    Nokogiri::HTML(open("https://www.lonelyplanet.com/best-in-travel/")).css("a.js-page-navigation-spot span").each_with_index do |list, index|
      puts "#{index+1}. #{list.text}"
    end
    puts "5. List of All Destinations"
  end

  def self.scrape_countries
    Nokogiri::HTML(open("https://www.lonelyplanet.com/best-in-travel/countries")).css(".marketing-article")
  end

  def self.scrape_cities
     Nokogiri::HTML(open("https://www.lonelyplanet.com/best-in-travel/cities")).css(".marketing-article")
  end

  def self.scrape_regions
    Nokogiri::HTML(open("https://www.lonelyplanet.com/best-in-travel/regions")).css(".marketing-article")
  end

  def self.scrape_value
    Nokogiri::HTML(open("https://www.lonelyplanet.com/best-in-travel/value")).css(".marketing-article")
  end


  def self.puts_countries
    self.scrape_countries.css(".marketing-article__header h1").each do |lists|
      puts lists.text
    end
  end

  def self.puts_cities
    self.scrape_cities.css(".marketing-article__header h1").each do |lists|
      puts lists.text
    end
  end

  def self.puts_regions
    self.scrape_regions.css(".marketing-article__header h1").each do |lists|
    puts lists.text
    end
  end


  def self.puts_value
    self.scrape_value.css(".marketing-article__header h1").each do |lists|
      puts lists.text
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
destinations-0.1.2 lib/destinations/travel_destinations.rb
destinations-0.1.1 lib/destinations/travel_destinations.rb