hotel_price 0.4.6 → 0.4.7
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/rakuten/rakuten_console.rb +29 -21
- 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: bc76b623cc53e04ce6b4e2b0c065c6cb70c4ee24f38ac6addc5a2c9ea22c04e3
|
4
|
+
data.tar.gz: 9818d73af51d8a53cf4e045defb37b328ca3d43bc0e1752eb2778c17805cbe7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68c6d5beaae5c53e71fdebf1122b8db3fe4e6c7d887fa1dd1acc1e58d1bf07b3947038942cb8872d623e08340b26f86e0d1db433960fbba43d792d7366ded705
|
7
|
+
data.tar.gz: 16144d0302ea1aa7b260639bcd8d41ae0c6c8899ad579228490d7c1509f9c997ef1f0f1e92a84122b5c619b00e0d3bc333c2effd243c77be67483b25410ea65b
|
@@ -5,16 +5,11 @@ module HotelPrice::Rakuten
|
|
5
5
|
login_id: params[:login_id],
|
6
6
|
login_pw: params[:login_pw],
|
7
7
|
chain: params[:chain] ||= false,
|
8
|
-
rakuten_hotel_id: params[:rakuten_hotel_id] ||= 0
|
8
|
+
rakuten_hotel_id: params[:rakuten_hotel_id] ||= 0,
|
9
|
+
mode: params[:mode] ||= 0
|
9
10
|
}
|
10
|
-
@wait = Selenium::WebDriver::Wait.new(:
|
11
|
-
|
12
|
-
# options = Selenium::WebDriver::Firefox::Options.new
|
13
|
-
# options.add_argument("-headless")
|
14
|
-
# @driver = Selenium::WebDriver.for :firefox, options: options
|
15
|
-
|
16
|
-
firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
|
17
|
-
@driver = Selenium::WebDriver.for(:remote, url: "http://hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
|
11
|
+
@wait = Selenium::WebDriver::Wait.new(timeout: 100)
|
12
|
+
@driver = get_selenium_driver @config[:mode]
|
18
13
|
if @config[:chain]
|
19
14
|
go_to_management_page_chain
|
20
15
|
else
|
@@ -22,6 +17,19 @@ module HotelPrice::Rakuten
|
|
22
17
|
end
|
23
18
|
end
|
24
19
|
|
20
|
+
def get_selenium_driver(mode = 0)
|
21
|
+
if mode == 1
|
22
|
+
firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
|
23
|
+
Selenium::WebDriver.for(:remote, url: "http://hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
|
24
|
+
elsif mode == 2
|
25
|
+
Selenium::WebDriver.for :firefox
|
26
|
+
else
|
27
|
+
options = Selenium::WebDriver::Firefox::Options.new
|
28
|
+
options.add_argument("-headless")
|
29
|
+
Selenium::WebDriver.for :firefox, options: options
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
25
33
|
def go_to_management_page_chain
|
26
34
|
@driver.get "https://manage.travel.rakuten.co.jp/portal/inn/ry_group.main"
|
27
35
|
@driver.find_element(:name, "f_id").send_keys @config[:login_id].to_s
|
@@ -104,7 +112,7 @@ module HotelPrice::Rakuten
|
|
104
112
|
(0..@plans.size - 1).each do |i|
|
105
113
|
plan = RakutenPlan.find_by(manage_number: @data[i][:manage_number])
|
106
114
|
@driver.find_element(:link_text, @data[i][:plan_name]).click
|
107
|
-
|
115
|
+
@driver.find_element(:xpath, "/html/body/form[4]/table[1]/tbody/tr/td/table/tbody[1]/tr[3]/td[2]").text
|
108
116
|
flag = []
|
109
117
|
flag[0] = "楽天トラベル[宿泊のみ]" if @driver.find_element(:name, "f_tabi_flg").selected?
|
110
118
|
|
@@ -288,7 +296,7 @@ module HotelPrice::Rakuten
|
|
288
296
|
room_size_tatami = ""
|
289
297
|
end
|
290
298
|
(0..5).each do |i|
|
291
|
-
|
299
|
+
@driver.find_element(:id, "view2_type_#{i}").attribute("value") if @driver.find_element(:id, "view2_type_#{i}").selected?
|
292
300
|
end
|
293
301
|
|
294
302
|
# Pause sort
|
@@ -331,7 +339,7 @@ module HotelPrice::Rakuten
|
|
331
339
|
password_exp_date: exp,
|
332
340
|
rakuten_hotel_id: rakuten_hotel_id
|
333
341
|
}
|
334
|
-
rescue => e
|
342
|
+
rescue StandardError => e
|
335
343
|
@driver.quit
|
336
344
|
{
|
337
345
|
status: "error",
|
@@ -340,7 +348,7 @@ module HotelPrice::Rakuten
|
|
340
348
|
end
|
341
349
|
|
342
350
|
def get_area_seo_rank
|
343
|
-
|
351
|
+
@driver.find_element(:xpath, "/html/body/table[2]/tbody/tr/td[3]/table[1]/tbody/tr[2]/td/table/tbody/tr[1]/td[5]/table/tbody/tr/td/table[1]/tbody/tr[5]/td[2]/font/b")
|
344
352
|
rows = @driver.find_elements(:xpath, "/html/body/table[2]/tbody/tr/td[3]/table[1]/tbody/tr[2]/td/table/tbody/tr[1]/td[5]/table/tbody/tr/td/table[1]/tbody/tr[5]")
|
345
353
|
rows.each do |f|
|
346
354
|
cells = f.find_elements(:css, "td").map(&:text)
|
@@ -355,7 +363,7 @@ module HotelPrice::Rakuten
|
|
355
363
|
|
356
364
|
def get_reservation_info
|
357
365
|
t = Time.now
|
358
|
-
|
366
|
+
@driver.find_element(:xpath, "/html/body/table[2]/tbody/tr/td[3]/table[3]/tbody/tr[2]/td[2]/table/tbody/tr[3]/td/input").click
|
359
367
|
if t.day == 1
|
360
368
|
last_month = degit2 t.prev_month.month.to_i
|
361
369
|
yesterday = degit2 t.prev_month.end_of_month.day.to_i
|
@@ -472,8 +480,8 @@ module HotelPrice::Rakuten
|
|
472
480
|
end
|
473
481
|
|
474
482
|
def daily_data_update
|
475
|
-
|
476
|
-
|
483
|
+
@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
|
484
|
+
@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
|
477
485
|
sleep 3
|
478
486
|
if Time.now.day == 1
|
479
487
|
else
|
@@ -485,7 +493,7 @@ module HotelPrice::Rakuten
|
|
485
493
|
select = Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "f_date"))
|
486
494
|
select.select_by(:value, value)
|
487
495
|
end
|
488
|
-
|
496
|
+
@driver.find_element(:xpath, '//input[@value = "表示"]').click
|
489
497
|
rows = @driver.find_elements(:xpath, "//tr")
|
490
498
|
rows[27..58].each do |row|
|
491
499
|
cells = row.find_elements(:css, "td[align=RIGHT]").map { |a| a.text.strip.gsub(",", "") }
|
@@ -514,9 +522,9 @@ module HotelPrice::Rakuten
|
|
514
522
|
end
|
515
523
|
|
516
524
|
def monthly_data_past
|
517
|
-
|
518
|
-
|
519
|
-
|
525
|
+
@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
|
526
|
+
@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[2]/input").click
|
527
|
+
@driver.find_element(:xpath, "/html/body/center/table[1]/tbody/tr[2]/td/table/tbody/tr[2]/td/form/input[8]").click
|
520
528
|
rows = @driver.find_elements(:xpath, "//tr")
|
521
529
|
rows[19..31].each do |row|
|
522
530
|
cells = row.find_elements(:css, "td").map { |a| a.text.strip.gsub(",", "") }
|
@@ -548,4 +556,4 @@ module HotelPrice::Rakuten
|
|
548
556
|
@driver.quit
|
549
557
|
end
|
550
558
|
end
|
551
|
-
end
|
559
|
+
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.
|
4
|
+
version: 0.4.7
|
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-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|