hotel_price 0.4.9 → 0.5.0
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/agoda/agoda_scraper.rb +12 -5
- data/lib/hotel_price/booking/booking_scraper.rb +12 -5
- data/lib/hotel_price/expedia/expedia_scraper.rb +12 -5
- data/lib/hotel_price/jalan/jalan_scraper.rb +57 -0
- data/lib/hotel_price/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e38f0cc8a2fa784a0d914f013934c8e3f5bc8bb862e5959f2025d7813d251c8
|
4
|
+
data.tar.gz: 24e3ef0bf32e8b93fd7de72fe2719f41568feef2d2d24f16779c54f38e24c740
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a77a876336f07c6ed05fd864225fb5f3b8fc596142071b8eccdcb073005687af2875601fde6736b84289ce7a64cc72a3f4d7c2d872e0f62b05a118f5c1986e82
|
7
|
+
data.tar.gz: a751e80850b237e3fe3ee870e89e70e09d83c072cec30da1ae8a25d32c0702c3db4e5f643c7ae2fbd2b81e9c5b2f38e25cb89b9a16b68899893ce4dbaa51f2cd
|
data/Gemfile.lock
CHANGED
@@ -7,7 +7,7 @@ module HotelPrice::Agoda
|
|
7
7
|
|
8
8
|
query_string = make_query_string(checkin_date.to_s, num_adults)
|
9
9
|
url = "https://www.agoda.com/ja-jp/#{agoda_hotel_id}.html?#{query_string}"
|
10
|
-
driver = self.get_selenium_driver
|
10
|
+
driver = self.get_selenium_driver mode
|
11
11
|
driver.get(url)
|
12
12
|
sleep 2
|
13
13
|
|
@@ -44,10 +44,17 @@ module HotelPrice::Agoda
|
|
44
44
|
"adults=#{num_adults}"
|
45
45
|
end
|
46
46
|
|
47
|
-
def self.get_selenium_driver
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
def self.get_selenium_driver(mode = 0)
|
48
|
+
if mode == 1
|
49
|
+
firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
|
50
|
+
Selenium::WebDriver.for(:remote, url: "http://selenium-hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
|
51
|
+
elsif mode == 2
|
52
|
+
Selenium::WebDriver.for :firefox
|
53
|
+
else
|
54
|
+
options = Selenium::WebDriver::Firefox::Options.new
|
55
|
+
options.add_argument("-headless")
|
56
|
+
Selenium::WebDriver.for :firefox, options: options
|
57
|
+
end
|
51
58
|
end
|
52
59
|
end
|
53
60
|
end
|
@@ -7,7 +7,7 @@ module HotelPrice::Booking
|
|
7
7
|
|
8
8
|
query_string = make_query_string(checkin_date.to_s, num_adults)
|
9
9
|
url = "https://www.booking.com/hotel/jp/#{booking_hotel_id}.ja.html?#{query_string}"
|
10
|
-
driver = self.get_selenium_driver
|
10
|
+
driver = self.get_selenium_driver mode
|
11
11
|
driver.get(url)
|
12
12
|
sleep 2
|
13
13
|
|
@@ -47,10 +47,17 @@ module HotelPrice::Booking
|
|
47
47
|
"group_adults=#{num_adults}&group_children=0"
|
48
48
|
end
|
49
49
|
|
50
|
-
def self.get_selenium_driver
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
def self.get_selenium_driver(mode = 0)
|
51
|
+
if mode == 1
|
52
|
+
firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
|
53
|
+
Selenium::WebDriver.for(:remote, url: "http://selenium-hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
|
54
|
+
elsif mode == 2
|
55
|
+
Selenium::WebDriver.for :firefox
|
56
|
+
else
|
57
|
+
options = Selenium::WebDriver::Firefox::Options.new
|
58
|
+
options.add_argument("-headless")
|
59
|
+
Selenium::WebDriver.for :firefox, options: options
|
60
|
+
end
|
54
61
|
end
|
55
62
|
end
|
56
63
|
end
|
@@ -7,7 +7,7 @@ module HotelPrice::Expedia
|
|
7
7
|
|
8
8
|
query_string = make_query_string(checkin_date.to_s, num_adults)
|
9
9
|
url = "https://www.expedia.co.jp/ja/#{expedia_hotel_id}.Hotel-Information?#{query_string}"
|
10
|
-
driver = self.get_selenium_driver
|
10
|
+
driver = self.get_selenium_driver mode
|
11
11
|
driver.get(url)
|
12
12
|
sleep 2
|
13
13
|
|
@@ -46,10 +46,17 @@ module HotelPrice::Expedia
|
|
46
46
|
"rm1=a#{num_adults}"
|
47
47
|
end
|
48
48
|
|
49
|
-
def self.get_selenium_driver
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
def self.get_selenium_driver(mode = 0)
|
50
|
+
if mode == 1
|
51
|
+
firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
|
52
|
+
Selenium::WebDriver.for(:remote, url: "http://selenium-hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
|
53
|
+
elsif mode == 2
|
54
|
+
Selenium::WebDriver.for :firefox
|
55
|
+
else
|
56
|
+
options = Selenium::WebDriver::Firefox::Options.new
|
57
|
+
options.add_argument("-headless")
|
58
|
+
Selenium::WebDriver.for :firefox, options: options
|
59
|
+
end
|
53
60
|
end
|
54
61
|
end
|
55
62
|
end
|
@@ -1,4 +1,61 @@
|
|
1
1
|
module HotelPrice::Jalan
|
2
2
|
class JalanScraper
|
3
|
+
def self.get_price(jalan_hotel_id, checkin_date, num_adults, mode = 0)
|
4
|
+
date = DateTime.now.strftime("%Y-%m-%d")
|
5
|
+
|
6
|
+
query_string = make_query_string(checkin_date.to_s, num_adults)
|
7
|
+
url = "https://www.jalan.net/yad#{jalan_hotel_id}/plan/?screenId=UWW3101&yadNo=#{jalan_hotel_id}&#{query_string}"
|
8
|
+
puts url
|
9
|
+
driver = self.get_selenium_driver mode
|
10
|
+
driver.get(url)
|
11
|
+
sleep 2
|
12
|
+
@price_box = []
|
13
|
+
driver.find_elements(class_name: "p-planCassette").each do |f|
|
14
|
+
rows = f.find_elements(:xpath, "//tr")
|
15
|
+
rows.each do |e|
|
16
|
+
@price_box << {
|
17
|
+
date: date,
|
18
|
+
min_price: e.find_element(class_name: "p-searchResultItem__total").text.delete("^0-9").to_i,
|
19
|
+
hotel_name: driver.find_element(id: "yado_header_hotel_name").text,
|
20
|
+
room_name: e.find_element(class_name: "p-searchResultItem__planName").text,
|
21
|
+
plan_name: f.find_element(class_name: "p-planCassette__header").text
|
22
|
+
}
|
23
|
+
rescue
|
24
|
+
end
|
25
|
+
end
|
26
|
+
@price_box.sort_by { |a, b, c| c }.reverse.first
|
27
|
+
rescue
|
28
|
+
{ date: date, min_price: 0 }
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.make_query_string(checkin_date, num_adults)
|
32
|
+
cd_args = make_date_args checkin_date
|
33
|
+
na_args = make_num_adults_arg num_adults
|
34
|
+
"rootCd=7701&callbackHistFlg=1&contHideFlg=1&reSearchFlg=1&roomCrack=100000&smlCd=121108&distCd=01&#{cd_args}&stayCount=1&roomCount=1&#{na_args}&minPrice=0&maxPrice=999999"
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.make_date_args checkin_date
|
38
|
+
Date.parse checkin_date rescue return ""
|
39
|
+
Date.parse(checkin_date).strftime("stayYear=%Y&stayMonth=%m&stayDay=%d")
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.make_num_adults_arg num_adults
|
43
|
+
return "" if num_adults.to_i < 1
|
44
|
+
"adultNum=#{num_adults}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.get_selenium_driver(mode = 0)
|
48
|
+
if mode == 1
|
49
|
+
firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
|
50
|
+
Selenium::WebDriver.for(:remote, url: "http://selenium-hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
|
51
|
+
elsif mode == 2
|
52
|
+
Selenium::WebDriver.for :firefox
|
53
|
+
else
|
54
|
+
options = Selenium::WebDriver::Firefox::Options.new
|
55
|
+
options.add_argument("-headless")
|
56
|
+
Selenium::WebDriver.for :firefox, options: options
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
3
60
|
end
|
4
61
|
end
|
data/lib/hotel_price/version.rb
CHANGED
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
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fumitake Kawasaki
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-04-
|
12
|
+
date: 2020-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|