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
34 35 36 37 38 39 40 41 42 43 |
# 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 ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# 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 ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# 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 ⇒ Object
47 48 49 50 51 52 53 54 55 |
# 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 ⇒ Object
58 59 60 61 62 63 64 65 66 |
# 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 ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# 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 ⇒ Object
81 82 83 84 85 86 87 88 89 |
# 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 ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# 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 ⇒ Object
102 103 104 105 106 107 108 109 110 111 |
# 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 ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# 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 |