hotel_price 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hotel_price/jalan/jalan_api.rb +18 -15
- data/lib/hotel_price/rakuten/rakuten_api.rb +19 -19
- data/lib/hotel_price/rakuten/rakuten_console.rb +4 -4
- data/lib/hotel_price/rakuten/rakuten_scraper.rb +3 -3
- data/lib/hotel_price/rakuten.rb +6 -5
- 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: d48fd88b537c417778f6d18610816db6576f4af18e8841e617b2d7cdb92e472d
|
4
|
+
data.tar.gz: dba3f92cc584db596f5ff2b3df6d4e32dd7fae421bd092a1c0aa25fd4748f7bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97608f3f9fc515dec4bdaed15935607da8d05dd26e99093ea9d4f5e2b1f9bbdd6db6e5c6fe27b5224cd0d5bcb1684f5c5c80afb9c50b238a9ccd8928b7a55512
|
7
|
+
data.tar.gz: 86c82ee4e6c5e3f8aa19c274e492f96017643adf0bedfeb272198e2256fc729ed84f223793f208fb240bd7199cc190171a7136aa3385fe94650a8b663034c2bd
|
@@ -8,30 +8,33 @@ module HotelPrice::Jalan
|
|
8
8
|
@api_key
|
9
9
|
end
|
10
10
|
|
11
|
-
def get_price
|
12
|
-
|
11
|
+
def get_price jalan_hotel_id, checkin_date, adult_num
|
12
|
+
url = "http://jws.jalan.net/APIAdvance/StockSearch/V1/?key=#{@api_key}&h_id=#{jalan_hotel_id}&stay_date=#{checkin_date}&stay_count=1&adult_num=#{adult_num}&count=1"
|
13
|
+
puts url
|
14
|
+
doc = Nokogiri::XML(open(url))
|
15
|
+
if doc.css("NumberOfResults").text == "0"
|
13
16
|
{
|
14
17
|
date: DateTime.now.strftime("%Y-%m-%d"),
|
15
|
-
branch_id:
|
16
|
-
stay_date:
|
17
|
-
adult_num:
|
18
|
-
jalan_hotel_id:
|
18
|
+
branch_id: request_body[:branch_id],
|
19
|
+
stay_date: request_body[:checkindate],
|
20
|
+
adult_num: request_body[:adult_num],
|
21
|
+
jalan_hotel_id: request_body[:jalan_hotel_id],
|
19
22
|
plan_num: 0,
|
20
23
|
min_price: 0
|
21
24
|
}
|
22
25
|
else
|
23
26
|
{
|
24
27
|
date: DateTime.now.strftime("%Y-%m-%d"),
|
25
|
-
branch_id:
|
28
|
+
branch_id: request_body[:branch_id],
|
26
29
|
channel: "jalan",
|
27
|
-
stay_date:
|
28
|
-
adult_num:
|
29
|
-
jalan_hotel_id:
|
30
|
-
hotel_name:
|
31
|
-
room_name:
|
32
|
-
plan_name:
|
33
|
-
plan_num:
|
34
|
-
min_price:
|
30
|
+
stay_date: request_body[:checkindate],
|
31
|
+
adult_num: request_body[:adult_num],
|
32
|
+
jalan_hotel_id: request_body[:jalan_hotel_id],
|
33
|
+
hotel_name: doc.css("Plan").css("Hotel HotelName").text,
|
34
|
+
room_name: doc.css("Plan").css("RoomName").text,
|
35
|
+
plan_name: doc.css("Plan").css("PlanName").text,
|
36
|
+
plan_num: doc.css("NumberOfResults").text,
|
37
|
+
min_price: doc.css("Plan").css("Stay Rate").text
|
35
38
|
}
|
36
39
|
end
|
37
40
|
end
|
@@ -2,8 +2,8 @@ module HotelPrice::Rakuten
|
|
2
2
|
class RakutenAPI
|
3
3
|
def initialize params
|
4
4
|
@config = {
|
5
|
-
|
6
|
-
|
5
|
+
rakuten_hotel_id: params[:rakuten_hotel_id] ||= 0,
|
6
|
+
rakuten_api_key: params[:rakuten_api_key] ||= ENV["RT_API_KEY"]
|
7
7
|
}
|
8
8
|
end
|
9
9
|
|
@@ -16,22 +16,22 @@ module HotelPrice::Rakuten
|
|
16
16
|
@result["hotels"][0].each do |_key, field|
|
17
17
|
field[0].each do |_, value|
|
18
18
|
@data_hash = {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
rakuten_hotel_id: value["hotelNo"],
|
20
|
+
hotel_name: value["hotelName"],
|
21
|
+
room_price_min: value["hotelMinCharge"],
|
22
|
+
lat: value["latitude"],
|
23
|
+
lon: value["longitude"],
|
24
|
+
tel: value["telephoneNo"],
|
25
|
+
zip_code: value["postalCode"],
|
26
|
+
prefecture: value["address1"],
|
27
|
+
address1: value["address2"],
|
28
|
+
fax: value["faxNo"],
|
29
|
+
access: value["access"],
|
30
|
+
parking_info: value["parkingInformation"],
|
31
|
+
near_station: value["nearestStation"],
|
32
|
+
hotel_img_url: value["hotelImageUrl"],
|
33
|
+
rakuten_review_count: value["reviewCount"],
|
34
|
+
rakuten_review_avg: value["reviewAverage"].to_f
|
35
35
|
}
|
36
36
|
end
|
37
37
|
end
|
@@ -75,4 +75,4 @@ module HotelPrice::Rakuten
|
|
75
75
|
@data_hash
|
76
76
|
end
|
77
77
|
end
|
78
|
-
end
|
78
|
+
end
|
@@ -2,10 +2,10 @@ module HotelPrice::Rakuten
|
|
2
2
|
class RakutenConsole
|
3
3
|
def initialize params
|
4
4
|
@config = {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
login_id: params[:login_id],
|
6
|
+
login_pw: params[:login_pw],
|
7
|
+
chain: params[:chain] ||= false,
|
8
|
+
rakuten_hotel_id: params[:rakuten_hotel_id] ||= 0,
|
9
9
|
}
|
10
10
|
end
|
11
11
|
end
|
@@ -7,9 +7,9 @@ module HotelPrice::Rakuten
|
|
7
7
|
comment_area = driver.find_elements(:class_name, "commentBox")
|
8
8
|
data = comment_area.map do |f|
|
9
9
|
{
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
date: f.find_element(class_name: "time").text,
|
11
|
+
rakuten_hotel_id: rakuten_hotel_id,
|
12
|
+
comment: f.find_element(class_name: "commentSentence").text
|
13
13
|
}
|
14
14
|
end
|
15
15
|
driver.quit
|
data/lib/hotel_price/rakuten.rb
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
require_relative "./rakuten/rakuten_api"
|
2
2
|
require_relative "./rakuten/rakuten_console"
|
3
|
+
require_relative "./rakuten/rakuten_scraper"
|
3
4
|
|
4
5
|
module HotelPrice
|
5
6
|
module Rakuten
|
6
7
|
def self.review rakuten_hotel_id
|
7
8
|
driver = self.get_selenium_driver
|
8
|
-
driver.get("https://travel.rakuten.co.jp/HOTEL/#{rakuten_hotel_id
|
9
|
+
driver.get("https://travel.rakuten.co.jp/HOTEL/#{rakuten_hotel_id}/review.html")
|
9
10
|
sleep 2
|
10
11
|
comment_area = driver.find_elements(:class_name, "commentBox")
|
11
12
|
data = comment_area.map do |f|
|
12
13
|
{
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
date: f.find_element(class_name: "time").text,
|
15
|
+
rakuten_hotel_id: rakuten_hotel_id,
|
16
|
+
comment: f.find_element(class_name: "commentSentence").text
|
16
17
|
}
|
17
18
|
end
|
18
19
|
driver.quit
|
19
20
|
data
|
20
21
|
end
|
21
22
|
end
|
22
|
-
end
|
23
|
+
end
|
data/lib/hotel_price/version.rb
CHANGED