Class: Travel::Scraper
- Inherits:
-
Object
- Object
- Travel::Scraper
- Defined in:
- lib/travel/scraper.rb
Class Method Summary collapse
- .scrape_all_inclusive_resorts ⇒ Object
- .scrape_attractions ⇒ Object
- .scrape_beaches ⇒ Object
- .scrape_destinations ⇒ Object
- .scrape_destinations_on_the_rise ⇒ Object
- .scrape_hotels ⇒ Object
- .scrape_islands ⇒ Object
- .scrape_landmarks ⇒ Object
- .scrape_museums ⇒ Object
- .scrape_restaurants ⇒ Object
Class Method Details
.scrape_all_inclusive_resorts ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/travel/scraper.rb', line 33 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 ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/travel/scraper.rb', line 20 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 ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/travel/scraper.rb', line 6 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 ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/travel/scraper.rb', line 46 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 ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/travel/scraper.rb', line 57 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 ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/travel/scraper.rb', line 69 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 ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/travel/scraper.rb', line 80 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 ⇒ Object
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/travel/scraper.rb', line 90 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 ⇒ Object
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/travel/scraper.rb', line 101 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 ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/travel/scraper.rb', line 112 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 |