shikiho 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d2a71f17540b9d7ba8ee0c55aa52a7024f241f62904b8ad069ab6934cc9db9d
4
- data.tar.gz: 4395efeb9c608888c56c511f5dcfc13796762d70640171921132b0bbbec15815
3
+ metadata.gz: 665d44731886a4ac12448b2c4bdb9c3a82ace3e005830a4cf9f0c8a6634cc018
4
+ data.tar.gz: f37cb7b495e8e5ec545c1513c724bc856ee754a76e0b932a9a89e7ffaa4a065d
5
5
  SHA512:
6
- metadata.gz: 1444a29de8208bc7882c1747c574ba40aca5f4ed591998f564613be05061f1f9b30a89cc57a6be0c0b8a97c6178387f5dca3f3544a0760a2074afe992e479233
7
- data.tar.gz: 186e815d0c522b82c16fffe7979906b59821e482ca88ed6e455a0de74e1f0a005f1b82e7d1577ba8f649333ac69f1423f40fe4bceb271d15d0471c73a066604a
6
+ metadata.gz: 18d1a149c5abbd34fc1f6003e0d39c54cef1463bd36e7506c4b4e7adbdff5c3d9fbe7b3bdd52c9d337094e834a01ce9592ace41cd0e257182bb2a1c280a2ef76
7
+ data.tar.gz: a03f50af30e9e5d61f243592d0271144dcb09d2d1f84f544d8665bd24c52a54811e68f913d3ef17cd89aad240996bc2de25705d88d9ffc1c2fa81e08ab572c88
data/Gemfile CHANGED
@@ -6,5 +6,5 @@ gemspec
6
6
  gem "nokogiri", "1.11.0"
7
7
  gem "rake", "12.3.3"
8
8
  gem "rspec", "~> 3.0"
9
- gem "selenium-webdriver", "2.53.4"
10
- gem "steep", "0.39.0"
9
+ gem "selenium-webdriver", "4.0.0.alpha7"
10
+ gem "steep", "0.39.0"
@@ -16,8 +16,7 @@ GEM
16
16
  ast_utils (0.3.0)
17
17
  parser (~> 2.4)
18
18
  thor (>= 0.19)
19
- childprocess (0.9.0)
20
- ffi (~> 1.0, >= 1.0.11)
19
+ childprocess (4.0.0)
21
20
  concurrent-ruby (1.1.7)
22
21
  diff-lcs (1.4.4)
23
22
  ffi (1.14.2)
@@ -52,10 +51,10 @@ GEM
52
51
  diff-lcs (>= 1.2.0, < 2.0)
53
52
  rspec-support (~> 3.10.0)
54
53
  rspec-support (3.10.1)
55
- rubyzip (1.3.0)
56
- selenium-webdriver (2.53.4)
57
- childprocess (~> 0.5)
58
- rubyzip (~> 1.0)
54
+ rubyzip (2.3.0)
55
+ selenium-webdriver (4.0.0.alpha7)
56
+ childprocess (>= 0.5, < 5.0)
57
+ rubyzip (>= 1.2.2)
59
58
  websocket (~> 1.0)
60
59
  steep (0.39.0)
61
60
  activesupport (>= 5.1)
@@ -79,7 +78,7 @@ DEPENDENCIES
79
78
  nokogiri (= 1.11.0)
80
79
  rake (= 12.3.3)
81
80
  rspec (~> 3.0)
82
- selenium-webdriver (= 2.53.4)
81
+ selenium-webdriver (= 4.0.0.alpha7)
83
82
  shikiho!
84
83
  steep (= 0.39.0)
85
84
 
@@ -8,10 +8,19 @@ module Shikiho
8
8
  class Error < StandardError; end
9
9
 
10
10
  def self.get_stock_price_now code:
11
+ i = 0
11
12
  driver = self.get_selenium_driver mode: :chrome
12
13
  driver.get("https://shikiho.jp/stocks/#{code.to_s}")
13
- sleep 5
14
- price = driver.find_element(:css, "div.current").text.to_s
14
+ sleep 3
15
+ begin
16
+ price = driver.find_element(:css, "div.current").text.to_s
17
+ rescue
18
+ puts "Retry... wait 2 sec.."
19
+ sleep 2
20
+ i += 1
21
+ raise StandardError, "Something wrong! Make sure your code exists" if i > 5
22
+ retry
23
+ end
15
24
  driver.quit
16
25
  { code: code, price: price, datetime: Time.now.utc }
17
26
  rescue StandardError => e
@@ -26,12 +35,12 @@ module Shikiho
26
35
  when :firefox
27
36
  Selenium::WebDriver.for :firefox
28
37
  else
29
- #options = Selenium::WebDriver::Chrome::Options.new
30
- # options.add_argument("--headless")
31
- # options.add_argument("--ignore-certificate-errors")
32
- # options.add_argument("--disable-popup-blocking")
33
- # options.add_argument("--disable-translate")
34
- Selenium::WebDriver.for :chrome#, options: options
38
+ options = Selenium::WebDriver::Chrome::Options.new
39
+ options.add_argument("--headless")
40
+ options.add_argument("--ignore-certificate-errors")
41
+ options.add_argument("--disable-popup-blocking")
42
+ options.add_argument("--disable-translate")
43
+ Selenium::WebDriver.for :chrome, options: options
35
44
  end
36
45
  end
37
46
  end
@@ -1,3 +1,3 @@
1
1
  module Shikiho
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shikiho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI