hotel_price 0.5.4 → 0.5.5
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 +1 -1
- data/lib/hotel_price/booking/booking_scraper.rb +1 -1
- data/lib/hotel_price/expedia/expedia_scraper.rb +1 -1
- data/lib/hotel_price/rakuten/rakuten_api.rb +2 -51
- data/lib/hotel_price/rakuten/rakuten_console.rb +0 -2
- data/lib/hotel_price/rakuten/rakuten_scraper.rb +3 -3
- 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: 936bc9b0a0c708967b88a86509f12e5a677f2b2ee6bcd88698154e801935418e
|
4
|
+
data.tar.gz: 01e264e7b9391bcb5e8f872f5097673665d2135c60ef94033a0b370105a7f376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8d200030f6757cea8ab13a2d93264bb1f34aff18784b93ad74f6295e6f6f54b5d3512276d4122cb99dcbcf601ca9f66abf2616e3889c022ca487dbc06a3d683
|
7
|
+
data.tar.gz: 438aaefa420b71023d57f6df72ee33f262347e54a8afdcda01a9f96607149aa32d51daf7751124f3853eab59f64f2e63ef1abb458bed6f46363b6ee27899ff52
|
data/Gemfile.lock
CHANGED
@@ -23,7 +23,7 @@ module HotelPrice::Agoda
|
|
23
23
|
room_name_element = driver.find_elements(:xpath, "//span[@data-selenium='masterroom-title-name']")
|
24
24
|
room_name = room_name_element.first.text unless room_name_element.empty?
|
25
25
|
|
26
|
-
{
|
26
|
+
{ checkin_date: checkin_date, min_price: price, hotel_name: hotel_name, room_name: room_name }
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.make_query_string(checkin_date, num_adults)
|
@@ -26,7 +26,7 @@ module HotelPrice::Booking
|
|
26
26
|
room_name_element = driver.find_elements(:class_name, "hprt-ws-roomtype-link")
|
27
27
|
room_name = room_name_element.first.text unless room_name_element.empty?
|
28
28
|
|
29
|
-
{
|
29
|
+
{ checkin_date: checkin_date, min_price: price, hotel_name: hotel_name, room_name: room_name }
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.make_query_string(checkin_date, num_adults)
|
@@ -23,7 +23,7 @@ module HotelPrice::Expedia
|
|
23
23
|
room_name_element = driver.find_elements(:xpath, "//h3[@data-stid='room-info-title-heading']")
|
24
24
|
room_name = room_name_element.first.text unless room_name_element.empty?
|
25
25
|
|
26
|
-
{
|
26
|
+
{ checkin_date: checkin_date, min_price: price, hotel_name: hotel_name, room_name: room_name }
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.make_query_string(checkin_date, num_adults)
|
@@ -2,7 +2,7 @@ module HotelPrice::Rakuten
|
|
2
2
|
class RakutenAPI
|
3
3
|
def initialize params
|
4
4
|
@config = {
|
5
|
-
rakuten_hotel_id: params[:rakuten_hotel_id] ||= 0,
|
5
|
+
rakuten_hotel_id: params[:rakuten_hotel_id].to_s ||= 0,
|
6
6
|
rakuten_api_key: params[:rakuten_api_key] ||= ENV["RT_API_KEY"]
|
7
7
|
}
|
8
8
|
end
|
@@ -45,56 +45,7 @@ module HotelPrice::Rakuten
|
|
45
45
|
"format=json&sort=%2BroomCharge&searchPattern=1&applicationId=#{@config[:rakuten_api_key]}&hotelNo=#{rakuten_hotel_id}&adultNum=#{num_adults}&checkinDate=#{checkin_date}&checkoutDate=#{checkout_date}&squeezeCondition="
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
params[:breakfast] ||= ""
|
50
|
-
try = 0
|
51
|
-
begin
|
52
|
-
base_url = "https://app.rakuten.co.jp/services/api/Travel/VacantHotelSearch/20131024?format=json&sort=%2BroomCharge&searchPattern=1"
|
53
|
-
url = [base_url, "&applicationId=", @config[:rakuten_api_key], "&adultNum=", params[:adult_num].to_s, "&checkinDate=", params[:checkin_date].to_s, "&checkoutDate=", (Date.parse(params[:checkin_date]) + 1).strftime("%Y-%m-%d"), "&hotelNo=", @config[:rakuten_hotel_id].to_s, "&squeezeCondition=", params[:breakfast]].join
|
54
|
-
json = Net::HTTP.get(URI.parse(url))
|
55
|
-
result = JSON.parse(json)
|
56
|
-
try = 0
|
57
|
-
begin
|
58
|
-
data_hash = if result["error"] == "not_found"
|
59
|
-
{
|
60
|
-
date: DateTime.now.strftime("%Y-%m-%d"),
|
61
|
-
checkin_date: params[:checkin_date],
|
62
|
-
rakuten_hotel_id: params[:rakuten_hotel_id],
|
63
|
-
adult_num: params[:adult_num],
|
64
|
-
breakfast: params[:breakfast],
|
65
|
-
plan_num: 0,
|
66
|
-
min_price: 0
|
67
|
-
}
|
68
|
-
elsif result["error"] == "wrong_parameterd"
|
69
|
-
"入力した値が正しくありません。"
|
70
|
-
else
|
71
|
-
{
|
72
|
-
date: DateTime.now.strftime("%Y-%m-%d"),
|
73
|
-
checkin_date: result["hotels"][0]["hotel"][1]["roomInfo"][1]["dailyCharge"]["stayDate"],
|
74
|
-
rakuten_hotel_id: params[:rakuten_hotel_id],
|
75
|
-
hotel_name: result["hotels"][0]["hotel"][0]["hotelBasicInfo"]["hotelName"],
|
76
|
-
adult_num: params[:adult_num],
|
77
|
-
breakfast: params[:breakfast],
|
78
|
-
plan_num: result["pagingInfo"]["recordCount"],
|
79
|
-
room_name: result["hotels"][0]["hotel"][1]["roomInfo"][0]["roomBasicInfo"]["roomName"],
|
80
|
-
plan_name: result["hotels"][0]["hotel"][1]["roomInfo"][0]["roomBasicInfo"]["planName"],
|
81
|
-
min_price: result["hotels"][0]["hotel"][1]["roomInfo"][1]["dailyCharge"]["rakutenCharge"]
|
82
|
-
}
|
83
|
-
end
|
84
|
-
rescue StandardError => e
|
85
|
-
try += 1
|
86
|
-
sleep 2
|
87
|
-
puts "エラー発生。リトライします。\n #{e.message}"
|
88
|
-
retry if try < 5
|
89
|
-
end
|
90
|
-
rescue StandardError => e
|
91
|
-
try += 1
|
92
|
-
sleep 5
|
93
|
-
retry if try < 5
|
94
|
-
end
|
95
|
-
data_hash
|
96
|
-
end
|
97
|
-
|
48
|
+
|
98
49
|
def hotel_info
|
99
50
|
uri = URI.parse("https://app.rakuten.co.jp/services/api/Travel/HotelDetailSearch/20131024?hotelNo=" + @config[:rakuten_hotel_id].to_s + "&applicationId=" + @config[:rakuten_api_key].to_s + "&datumType=1&responseType=large")
|
100
51
|
json = Net::HTTP.get(uri)
|
@@ -462,7 +462,6 @@ module HotelPrice::Rakuten
|
|
462
462
|
# end
|
463
463
|
|
464
464
|
def daily_data
|
465
|
-
puts "start"
|
466
465
|
@driver.find_element(:xpath, "/html/body/table[2]/tbody/tr/td[3]/table[2]/tbody/tr[1]/td[1]/table/tbody/tr/td[3]/a/img").click
|
467
466
|
@driver.find_element(:xpath, "/html/body/table[2]/tbody/tr/td[3]/table[5]/tbody/tr[2]/td[1]/table/tbody/tr[3]/td/table/tbody/tr/td[1]/input").click
|
468
467
|
sleep 3
|
@@ -476,7 +475,6 @@ module HotelPrice::Rakuten
|
|
476
475
|
select = Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "f_date"))
|
477
476
|
select.select_by(:value, value)
|
478
477
|
end
|
479
|
-
puts "scraper"
|
480
478
|
@driver.find_element(:xpath, '//input[@value = "表示"]').click
|
481
479
|
rows = @driver.find_elements(:xpath, "//tr")
|
482
480
|
data = []
|
@@ -84,7 +84,7 @@ module HotelPrice::Rakuten
|
|
84
84
|
driver.get "https://hotel.travel.rakuten.co.jp/hotelinfo/plan/#{rakuten_hotel_id}"
|
85
85
|
driver.find_element(:id, "focus1").click
|
86
86
|
driver.find_element(:id, "dh-squeezes-submit").click
|
87
|
-
sleep
|
87
|
+
sleep 3
|
88
88
|
plan_num = driver.find_elements(:class, "planThumb")
|
89
89
|
driver.quit
|
90
90
|
plan_num.size
|
@@ -93,10 +93,10 @@ module HotelPrice::Rakuten
|
|
93
93
|
def self.get_dayuse_plan_num rakuten_hotel_id, mode = 0
|
94
94
|
driver = HotelPrice.get_selenium_driver mode
|
95
95
|
driver.get "https://hotel.travel.rakuten.co.jp/hotelinfo/plan/#{rakuten_hotel_id}"
|
96
|
-
sleep
|
96
|
+
sleep 5
|
97
97
|
driver.find_element(:id, "du-radio").click
|
98
98
|
driver.find_element(:id, "dh-submit").click
|
99
|
-
sleep
|
99
|
+
sleep 5
|
100
100
|
plan_num = driver.find_elements(:class, "planThumb")
|
101
101
|
driver.quit
|
102
102
|
plan_num.size
|
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.5.
|
4
|
+
version: 0.5.5
|
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-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|