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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/hotel_price/rakuten/rakuten_scraper.rb +25 -16
- data/lib/hotel_price/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98b5a3b50fe4081d4f8a3415fda4e9cef549945952e4dff0ed857edb01821734
|
4
|
+
data.tar.gz: afc2199c849cd59933eaa515ec9456dfd0bc0b69174d852a5aabedc4a2998df2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e32918fc77c7808cc81d11c9f3b21935cc983c923305046d4f8a49fdb9a771a1fcf5b367afe0018bc89e46016d210376c1bb08ca9ef78575ff83d995b7bbca2
|
7
|
+
data.tar.gz: b98c58be5c87b6823ce9b9dc59ffbf63f14aaa38d9bf9acccebd1de3c3da81241b7254c45025e7cc8ce8d43990a9e78f5adce669ae60157f033d511f68c0e784
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
data/lib/hotel_price/version.rb
CHANGED