Module: HotelPrice::Rakuten

Defined in:
lib/hotel_price/rakuten.rb,
lib/hotel_price/rakuten/rakuten_api.rb,
lib/hotel_price/rakuten/rakuten_scraper.rb

Defined Under Namespace

Classes: RakutenAPI, RakutenScraper

Class Method Summary collapse

Class Method Details

.review(rakuten_hotel_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hotel_price/rakuten.rb', line 6

def self.review rakuten_hotel_id
  driver = self.get_selenium_driver
  driver.get("https://travel.rakuten.co.jp/HOTEL/#{rakuten_hotel_id}/review.html")
  sleep 2
  comment_area = driver.find_elements(:class_name, "commentBox")
  data = comment_area.map do |f|
    {
      date: f.find_element(class_name: "time").text,
      rakuten_hotel_id: rakuten_hotel_id,
      comment: f.find_element(class_name: "commentSentence").text
    }
  end
  driver.quit
  data
end