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)
region_array = []
doc.search("#tcRegions .tocContainer a").collect do |regionnode|
name = regionnode.text
sub_url = regionnode.attribute("href").value
region_array << {
:name => name,
:region_url => "https://www.tripadvisor.com#{sub_url}"
}
end region_array
end
|