class Travel::Scraper

Public Class Methods

scrape_all_inclusive_resorts() click to toggle source
# File lib/travel/scraper.rb, line 34
def self.scrape_all_inclusive_resorts
  doc = Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-AllInclusive-cTop-g1"))
  category = doc.css("h1.laurelhdr").text

  winners = doc.css("div.posRel.tcInner").map do |winner|
    name = winner.css(".mainName a").first.text
    location = winner.css(".smaller a").first.text
    AllInclusiveResort.new(name, location)
  end
end
scrape_attractions() click to toggle source
# File lib/travel/scraper.rb, line 21
def self.scrape_attractions
  doc = Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Attractions"))
  category = doc.css("h1.laurelhdr").text

  winners = doc.css("div.posRel.tcInner").map do |winner|
    name = winner.css(".mainName a").first.text
    location = winner.css(".smaller a").first.text
    Attraction.new(name, location)
  end
end
scrape_beaches() click to toggle source
# File lib/travel/scraper.rb, line 7
def self.scrape_beaches
  doc = Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Beaches"))
  category = doc.css("h1.laurelhdr").text
  
  winners = doc.css("div.posRel.tcInner").map do |winner|
    name = winner.css(".mainName a").first.text
    location = winner.css(".smaller a").first.text
    best_time = winner.css(".besttime").text
    Beach.new(name, location, best_time)
  end
end
scrape_destinations() click to toggle source
# File lib/travel/scraper.rb, line 47
def self.scrape_destinations
  doc = Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Destinations"))
  category = doc.css("h1.laurelhdr").text

  winners = doc.css("div.posRel.tcInner").map do |winner|
    name = winner.css(".mainName a").first.text
    Destination.new(name)
  end
end
scrape_destinations_on_the_rise() click to toggle source
# File lib/travel/scraper.rb, line 58
def self.scrape_destinations_on_the_rise
  doc = Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-DestinationsontheRise"))
  category = doc.css("h1.laurelhdr").text

  winners = doc.css("div.posRel.tcInner").map do |winner|
    name = winner.css(".mainName a").first.text
    DestinationOntheRise.new(name)
  end
end
scrape_hotels() click to toggle source
# File lib/travel/scraper.rb, line 70
def self.scrape_hotels
  doc = Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Hotels"))
  category = doc.css("h1.laurelhdr").text

  winners = doc.css("div.posRel.tcInner").map do |winner|
    name = winner.css(".mainName.extra a").first.text
    location = winner.css(".smaller a").first.text
    Hotel.new(name, location)
  end
end
scrape_islands() click to toggle source
# File lib/travel/scraper.rb, line 81
def self.scrape_islands
  doc = Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Islands"))
  category = doc.css("h1.laurelhdr").text

  winners = doc.css("div.posRel.tcInner").map do |winner|
    name = winner.css(".mainName a").first.text
    Island.new(name)
  end   
end
scrape_landmarks() click to toggle source
# File lib/travel/scraper.rb, line 91
def self.scrape_landmarks
  doc = Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Landmarks"))
  category = doc.css("h1.laurelhdr").text

  winners = doc.css("div.posRel.tcInner").map do |winner|
    name = winner.css(".mainName a").first.text
    location = winner.css(".smaller a").first.text
    Landmark.new(name, location)
  end
end
scrape_museums() click to toggle source
# File lib/travel/scraper.rb, line 102
def self.scrape_museums
  doc = Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Museums"))
  category = doc.css("h1.laurelhdr").text

  winners = doc.css("div.posRel.tcInner").map do |winner|
    name = winner.css(".mainName.extra a").first.text
    location = winner.css(".smaller a").first.text
    Museum.new(name, location)
  end
end
scrape_restaurants() click to toggle source
# File lib/travel/scraper.rb, line 113
def self.scrape_restaurants
  doc = Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Restaurants"))
  category = doc.css("h1.laurelhdr").text
  
  winners = doc.css("div.posRel.tcInner").map do |winner|
    name = winner.css(".mainName a").first.text
    location = winner.css(".smaller a").first.text
    cuisine = winner.css(".cuisineTypes").text
    Restaurant.new(name, location, cuisine)
  end
end