hotel_price 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f11db6a218402ed66a5b38636651f60ad2254925f7214ed2d5066c8a8d119e0
4
- data.tar.gz: 1e8080a6c350b3826197fbed5c005969adc3320e0f140fd89baa5e9cef793126
3
+ metadata.gz: 98b5a3b50fe4081d4f8a3415fda4e9cef549945952e4dff0ed857edb01821734
4
+ data.tar.gz: afc2199c849cd59933eaa515ec9456dfd0bc0b69174d852a5aabedc4a2998df2
5
5
  SHA512:
6
- metadata.gz: 2e3a2539ffc8f2e05273b863f0a7ebdd265dac1d61486f1e5392371cc95d499d0390ae6286c71ba73cafc3764ca8ec80ac765397fee4be2bab810c0097b3d38f
7
- data.tar.gz: 578761c339e4e77b12b2bc929fb78fdf49fb906f58d24ce7fb56b8001065258298c3a29fd964060c09c1f1713e64211fa56f556e123bb11e5303ae8dfd933bc7
6
+ metadata.gz: 5e32918fc77c7808cc81d11c9f3b21935cc983c923305046d4f8a49fdb9a771a1fcf5b367afe0018bc89e46016d210376c1bb08ca9ef78575ff83d995b7bbca2
7
+ data.tar.gz: b98c58be5c87b6823ce9b9dc59ffbf63f14aaa38d9bf9acccebd1de3c3da81241b7254c45025e7cc8ce8d43990a9e78f5adce669ae60157f033d511f68c0e784
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hotel_price (0.4.2)
4
+ hotel_price (0.4.5)
5
5
  activesupport (~> 6.0.2.1)
6
6
  json (~> 2.3.0)
7
7
  nokogiri (~> 1.10.9)
@@ -1,7 +1,10 @@
1
1
  module HotelPrice::Rakuten
2
+ ## mode 0 - headless
3
+ ## mode 1 - docker selenium
4
+ ## mode 2 - debug
2
5
  class RakutenScraper
3
- def self.review rakuten_hotel_id
4
- driver = self.get_selenium_driver
6
+ def self.review rakuten_hotel_id, mode = 0
7
+ driver = self.get_selenium_driver mode
5
8
  driver.get("https://travel.rakuten.co.jp/HOTEL/#{rakuten_hotel_id.to_s}/review.html")
6
9
  sleep 2
7
10
  comment_area = driver.find_elements(:class_name, "commentBox")
@@ -29,8 +32,8 @@ module HotelPrice::Rakuten
29
32
  data
30
33
  end
31
34
 
32
- def self.get_photo_num rakuten_hotel_id
33
- driver = self.get_selenium_driver
35
+ def self.get_photo_num rakuten_hotel_id, mode = 0
36
+ driver = self.get_selenium_driver mode
34
37
  driver.get "https://hotel.travel.rakuten.co.jp/hinfo/#{rakuten_hotel_id}/"
35
38
  sleep 2
36
39
  num = driver.find_element(:id, "navPht").text.gsub("写真・動画(", "").gsub(")", "").to_i
@@ -38,8 +41,8 @@ module HotelPrice::Rakuten
38
41
  num
39
42
  end
40
43
 
41
- def self.get_bf_plan_num rakuten_hotel_id
42
- driver = self.get_selenium_driver
44
+ def self.get_bf_plan_num rakuten_hotel_id, mode = 0
45
+ driver = self.get_selenium_driver mode
43
46
  driver.get "https://hotel.travel.rakuten.co.jp/hotelinfo/plan/#{rakuten_hotel_id}"
44
47
  driver.find_element(:id, "focus1").click
45
48
  driver.find_element(:id, "dh-squeezes-submit").click
@@ -49,8 +52,8 @@ module HotelPrice::Rakuten
49
52
  plan_num.size
50
53
  end
51
54
 
52
- def self.get_dayuse_plan_num rakuten_hotel_id
53
- driver = self.get_selenium_driver
55
+ def self.get_dayuse_plan_num rakuten_hotel_id, mode = 0
56
+ driver = self.get_selenium_driver mode
54
57
  driver.get "https://hotel.travel.rakuten.co.jp/hotelinfo/plan/#{rakuten_hotel_id}"
55
58
  sleep 10
56
59
  driver.find_element(:id, "du-radio").click
@@ -61,8 +64,8 @@ module HotelPrice::Rakuten
61
64
  plan_num.size
62
65
  end
63
66
 
64
- def self.get_detail_class_code rakuten_hotel_id
65
- driver = self.get_selenium_driver
67
+ def self.get_detail_class_code rakuten_hotel_id, mode = 0
68
+ driver = self.get_selenium_driver mode
66
69
  driver.get "https://hotel.travel.rakuten.co.jp/hinfo/?f_no=#{rakuten_hotel_id}"
67
70
  {
68
71
  status: "found",
@@ -75,12 +78,18 @@ module HotelPrice::Rakuten
75
78
  }
76
79
  end
77
80
 
78
- def self.get_selenium_driver
79
- firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
80
- Selenium::WebDriver.for(:remote, url: "http://hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
81
- # options = Selenium::WebDriver::Firefox::Options.new
82
- # options.add_argument("-headless")
83
- # Selenium::WebDriver.for :firefox, options: options
81
+
82
+ def self.get_selenium_driver(mode = 0)
83
+ if mode == 1
84
+ firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
85
+ Selenium::WebDriver.for(:remote, url: "http://hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
86
+ elsif mode == 2
87
+ Selenium::WebDriver.for :firefox
88
+ else
89
+ options = Selenium::WebDriver::Firefox::Options.new
90
+ options.add_argument("-headless")
91
+ Selenium::WebDriver.for :firefox, options: options
92
+ end
84
93
  end
85
94
 
86
95
  end
@@ -1,3 +1,3 @@
1
1
  module HotelPrice
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotel_price
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fumitake Kawasaki