Class: TopTenIslandsCliGem::Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/top_ten_islands_cli_gem/scraper.rb

Class Method Summary collapse

Class Method Details

.get_island_discription(index) ⇒ Object



24
25
26
27
28
# File 'lib/top_ten_islands_cli_gem/scraper.rb', line 24

def self.get_island_discription(index)
  # Nokogiri::HTML(open(url)).css(" .ermb_text").css(" .content").text.strip
      
  @@top_islands_page.css('p')[index].text.strip
end

.get_islands_arrayObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/top_ten_islands_cli_gem/scraper.rb', line 9

def self.get_islands_array
  islands_array = []

  @@top_islands_page = self.get_page.css('.article__content')
  
  @@top_islands_page.css(' h3 > strong')
    .each_with_index do |island, index|
     island_hash = {}
     island_hash[:name] = island.text
     island_hash[:index] = index
     islands_array.push(island_hash)
  end
  islands_array
end

.get_pageObject



3
4
5
6
7
# File 'lib/top_ten_islands_cli_gem/scraper.rb', line 3

def self.get_page
  # Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Islands"))
  Nokogiri::HTML(open("https://www.lonelyplanet.com/campaign/island-guide-2018/top-10-islands-for-2018/"))
  
end