hotel_price 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a15be651d24b2be15d291114fa91cc82d1ef8a1cf140c9564ca466173b22fe58
4
- data.tar.gz: af0612a4bbd76192a0134d6f270a81826b10200c6fe4a018e4a83f99485c1a45
3
+ metadata.gz: d48fd88b537c417778f6d18610816db6576f4af18e8841e617b2d7cdb92e472d
4
+ data.tar.gz: dba3f92cc584db596f5ff2b3df6d4e32dd7fae421bd092a1c0aa25fd4748f7bf
5
5
  SHA512:
6
- metadata.gz: 8cb17881077dcb30af86c4ee9c1fa4fa6bdd771a6f793e704220b6ff71906eb214b370b20504f7295e027f93e37e3f04649435ac7725398c09290ca7c3fff2a2
7
- data.tar.gz: 20c350c2803d53101489e5cdd89fc99da33ff8097f900aeb11ac661acb89fb9d731bc1d6b826d7b182ad7d086be2ee03f94fe376c888939d45073287aef9b857
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
- if @doc.css("NumberOfResults").text == "0"
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: @user_info[:branch_id],
16
- stay_date: @user_info[:checkindate],
17
- adult_num: @user_info[:adult_num],
18
- jalan_hotel_id: @user_info[: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: @user_info[:branch_id],
28
+ branch_id: request_body[:branch_id],
26
29
  channel: "jalan",
27
- stay_date: @user_info[:checkindate],
28
- adult_num: @user_info[:adult_num],
29
- jalan_hotel_id: @user_info[:jalan_hotel_id],
30
- hotel_name: @doc.css("Plan").css("Hotel HotelName").text,
31
- room_name: @doc.css("Plan").css("RoomName").text,
32
- plan_name: @doc.css("Plan").css("PlanName").text,
33
- plan_num: @doc.css("NumberOfResults").text,
34
- min_price: @doc.css("Plan").css("Stay Rate").text
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
- rakuten_hotel_id: params[:rakuten_hotel_id] ||= 0,
6
- rakuten_api_key: params[:rakuten_api_key] ||= ENV["RT_API_KEY"]
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
- 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
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
- 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,
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
- date: f.find_element(class_name: "time").text,
11
- rakuten_hotel_id: rakuten_hotel_id,
12
- comment: f.find_element(class_name: "commentSentence").text
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
@@ -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.to_s}/review.html")
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
- date: f.find_element(class_name: "time").text,
14
- rakuten_hotel_id: rakuten_hotel_id,
15
- comment: f.find_element(class_name: "commentSentence").text
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
@@ -1,3 +1,3 @@
1
1
  module HotelPrice
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
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.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fumitake Kawasaki