module HotelPrice

Constants

VERSION

Attributes

configuration[RW]

Public Class Methods

configure() { |configuration| ... } click to toggle source
# File lib/hotel_price.rb, line 18
def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
end
rakuten_travel() click to toggle source
# File lib/hotel_price.rb, line 23
def self.rakuten_travel
  driver = self.get_selenium_driver
  rakuten_travel_hotel_id = 128552
  driver.get("https://travel.rakuten.co.jp/HOTEL/#{rakuten_travel_hotel_id}/review.html")
  sleep 2
  comment_area = driver.find_elements(:class_name, "commentReputationBoth")
  comment_area.map do |f|
    {
      status: "success",
      date: f.find_element(class_name: "time").text,
      rakuten_hotel_id: rakuten_travel_hotel_id,
      comment: f.find_element(class_name: "commentSentence").text
    }
  end
end

Protected Class Methods

get_selenium_driver(mode = :chrome) click to toggle source
# File lib/hotel_price.rb, line 41
def self.get_selenium_driver(mode = :chrome)
  case mode
  when :firefox_remote_capabilities
    firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
    Selenium::WebDriver.for(:remote, url: "http://hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
  when :firefox
    Selenium::WebDriver.for :firefox
  else
    options = Selenium::WebDriver::Chrome::Options.new
    options.add_argument("--ignore-certificate-errors")
    options.add_argument("--disable-popup-blocking")
    options.add_argument("--disable-translate")
    options.add_argument("-headless")
    Selenium::WebDriver.for :chrome, options: options
  end
end