class TopTravelDestinations::Scraper
Public Class Methods
scrape_regions_array()
click to toggle source
# File lib/top_travel_destinations/scraper.rb, line 3 def self.scrape_regions_array index_url = "https://www.tripadvisor.com/TravelersChoice-Destinations" html = open(index_url) doc = Nokogiri::HTML(html) regions_array = [] doc.search("div.cont a").collect do |regionnode| name = regionnode.text sub_url = regionnode.attribute("href").value regions_array << { :name => name, :region_url => "https://www.tripadvisor.com#{sub_url}" } end #end iterator regions_array end