Class: TopTravelDestinations::Scraper
- Inherits:
-
Object
- Object
- TopTravelDestinations::Scraper
- Defined in:
- lib/top_travel_destinations/scraper.rb
Class Method Summary collapse
Class Method Details
.scrape_regions_array ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# 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 |