rakuten_securities_scraper 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +26 -55
- data/.ruby-version +1 -0
- data/Gemfile +6 -5
- data/Gemfile.lock +36 -30
- data/lib/rakuten_securities_scraper.rb +21 -17
- data/lib/rakuten_securities_scraper/version.rb +1 -1
- data/rakuten_securities_scraper.gemspec +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a61a30f6ff13a24491e442e47b7d3d2e413aca237d6da3d50be7b585da487b3
|
4
|
+
data.tar.gz: ccdb20343aa853523d011a4ff22bbb7e5e64c1ca4c3a46aa7261df9ed57a1c2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4e23de3f5a09272fa8d3953a6dc0431f60f752752627b3dedc992ce8881b8d9b2c1bd595be652df9e710a94080024660f778bcb268f5448db7158afa25f4dfe
|
7
|
+
data.tar.gz: e85966fa71566fdec57c4b43a2f6b0e4b59c8408866f5dfa0e8d914ae07a7b5792b4b813ec0eefbc0ab6db36a4ac9441b3bf38b2be864a1508656cc3c59cb5ec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
AllCops:
|
2
2
|
EnabledByDefault: true
|
3
3
|
|
4
|
-
##################### Style ##################################
|
5
|
-
|
6
|
-
# redirect_to xxx and return のイディオムを維持したい
|
7
4
|
Style/AndOr:
|
8
5
|
Enabled: false
|
9
6
|
|
10
|
-
|
7
|
+
Style/ClassAndModuleChildren:
|
8
|
+
Enabled: false
|
9
|
+
|
11
10
|
Style/AsciiComments:
|
12
11
|
Enabled: false
|
13
12
|
|
@@ -36,19 +35,15 @@ Style/CollectionMethods:
|
|
36
35
|
inject: "inject"
|
37
36
|
reduce: "inject"
|
38
37
|
|
39
|
-
# ドキュメントの無い public class を許可する
|
40
38
|
Style/Documentation:
|
41
39
|
Enabled: false
|
42
40
|
|
43
|
-
# !! のイディオムは積極的に使う
|
44
41
|
Style/DoubleNegation:
|
45
42
|
Enabled: false
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
# メソッドチェーンの改行は末尾に . を入れる
|
51
|
-
# REPL に貼り付けた際の暴発を防ぐため
|
44
|
+
Lint/ConstantResolution:
|
45
|
+
Enabled: false
|
46
|
+
|
52
47
|
Layout/DotPosition:
|
53
48
|
EnforcedStyle: trailing
|
54
49
|
|
@@ -56,123 +51,89 @@ Layout/DotPosition:
|
|
56
51
|
Layout/EmptyLineAfterGuardClause:
|
57
52
|
Enabled: false
|
58
53
|
|
59
|
-
# 明示的に else で nil を返すのは分かりやすいので許可する
|
60
54
|
Style/EmptyElse:
|
61
55
|
EnforcedStyle: empty
|
62
56
|
|
63
|
-
# 桁揃えが綺麗にならないことが多いので migration は除外
|
64
57
|
Layout/ExtraSpacing:
|
65
58
|
Exclude:
|
66
59
|
- "db/migrate/*.rb"
|
60
|
+
- "*.gemspec"
|
67
61
|
|
68
|
-
# いずれかに揃えるのならば `sprintf` や `format` より String#% が好きです
|
69
62
|
Style/FormatString:
|
70
63
|
EnforcedStyle: percent
|
71
64
|
|
72
|
-
|
65
|
+
Style/MissingElse:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
Style/StringHashKeys:
|
69
|
+
Exclude:
|
70
|
+
- "spec/queries/*.rb"
|
71
|
+
- "*.gemspec"
|
72
|
+
|
73
73
|
Style/GuardClause:
|
74
74
|
MinBodyLength: 5
|
75
75
|
|
76
|
-
# rake タスクの順序の hash は rocket を許可する
|
77
76
|
Style/HashSyntax:
|
78
77
|
EnforcedStyle: ruby19
|
79
78
|
Exclude:
|
80
79
|
- "**/*.rake"
|
81
80
|
- "Rakefile"
|
82
81
|
|
83
|
-
# 条件式の方を意識させたい場合には後置の if/unless を使わない方が分かりやすい
|
84
82
|
Style/IfUnlessModifier:
|
85
83
|
Enabled: false
|
86
84
|
|
87
|
-
# private/protected は一段深くインデントする
|
88
85
|
Style/PreferredHashMethods:
|
89
86
|
EnforcedStyle: short
|
90
87
|
|
91
|
-
# scope 等は複数行でも lambda ではなく ->{} で揃えた方が見た目が綺麗
|
92
88
|
Style/Lambda:
|
93
89
|
Enabled: false
|
94
90
|
|
95
|
-
# 1_000_000 と区切り文字が 2 個以上必要になる場合のみ _ 区切りを必須にする
|
96
91
|
Style/NumericLiterals:
|
97
92
|
MinDigits: 7
|
98
93
|
|
99
|
-
# 正規表現にマッチさせた時の特殊変数の置き換えは Regex.last_match ではなく
|
100
|
-
# 名前付きキャプチャを使って参照したいので auto-correct しない
|
101
94
|
Style/PerlBackrefs:
|
102
95
|
AutoCorrect: false
|
103
96
|
|
104
|
-
# 特に model 内において、ローカル変数とメソッド呼び出しの区別をつけた方が分かりやすい場合が多い
|
105
97
|
Style/RedundantSelf:
|
106
98
|
Enabled: false
|
107
99
|
|
108
100
|
Style/FrozenStringLiteralComment:
|
109
101
|
Enabled: false
|
110
102
|
|
111
|
-
# 受け取り側で multiple assignment しろというのを明示
|
112
103
|
Style/RedundantReturn:
|
113
104
|
AllowMultipleReturnValues: true
|
114
105
|
|
115
|
-
# spec 内は見た目が綺麗になるので許可
|
116
106
|
Style/Semicolon:
|
117
107
|
Exclude:
|
118
108
|
- "spec/**/*"
|
119
109
|
|
120
|
-
# fail と使い分ける必要ナシ
|
121
110
|
Style/SignalException:
|
122
111
|
EnforcedStyle: only_raise
|
123
112
|
|
124
113
|
Style/MethodDefParentheses:
|
125
114
|
Enabled: false
|
126
115
|
|
127
|
-
# `||` も align に使うことがあるので追加する
|
128
|
-
# Style/SpaceAroundOperators:
|
129
|
-
# MultiSpaceAllowedForOperators:
|
130
|
-
# - "="
|
131
|
-
# - "=>"
|
132
|
-
# - "||"
|
133
|
-
|
134
|
-
# * 式展開したい場合に書き換えるのが面倒
|
135
|
-
# * 文章ではダブルクォートよりもシングルクォートの方が頻出する
|
136
|
-
# ことから EnforcedStyle: double_quotes 推奨
|
137
116
|
Style/StringLiterals:
|
138
117
|
EnforcedStyle: double_quotes
|
139
118
|
|
140
|
-
# auto-correct 時に Style/StringLiterals とカニバって無限ループになる (v0.28.0)
|
141
119
|
Style/StringLiteralsInInterpolation:
|
142
120
|
Enabled: false
|
143
121
|
|
144
|
-
# いくらなんでも inject { |a, e| } は短すぎるので分かりやすい名前をつけたい
|
145
122
|
Style/SingleLineBlockParams:
|
146
123
|
Enabled: false
|
147
124
|
|
148
|
-
# * migrate
|
149
|
-
# * jbuilder
|
150
|
-
# * model の association
|
151
|
-
# * controller の callback
|
152
|
-
# 辺りの桁揃えで引っかかるので全体的にチェックしない
|
153
|
-
# Style/SingleSpaceBeforeFirstArg:
|
154
|
-
# Enabled: false
|
155
|
-
|
156
|
-
|
157
|
-
##################### Lint ##################################
|
158
|
-
|
159
|
-
# * 同名のメソッドがある場合にローカル変数に `_` を付ける
|
160
|
-
# * 一時変数として `_` を付ける
|
161
|
-
# というテクニックは頻出する
|
162
125
|
Lint/UnderscorePrefixedVariableName:
|
163
126
|
Enabled: false
|
164
127
|
|
165
|
-
# 子クラスで実装させるつもりのメソッドで引っかかるので
|
166
128
|
Lint/UnusedMethodArgument:
|
167
129
|
Enabled: false
|
168
130
|
|
169
|
-
##################### Metrics ##################################
|
170
131
|
|
171
132
|
Metrics/AbcSize:
|
172
133
|
Enabled: false
|
173
134
|
|
174
135
|
Metrics/CyclomaticComplexity:
|
175
|
-
|
136
|
+
Max: 10
|
176
137
|
|
177
138
|
Metrics/PerceivedComplexity:
|
178
139
|
Enabled: false
|
@@ -222,5 +183,15 @@ Style/MutableConstant:
|
|
222
183
|
Enabled: false
|
223
184
|
Style/Copyright:
|
224
185
|
Enabled: false
|
186
|
+
Style/MultilineTernaryOperator:
|
187
|
+
Enabled: false
|
225
188
|
Layout/MultilineAssignmentLayout:
|
189
|
+
Enabled: false
|
190
|
+
Style/Send:
|
191
|
+
Enabled: false
|
192
|
+
Style/RedundantFileExtensionInRequire:
|
193
|
+
Enabled: false
|
194
|
+
Style/ClassMethodsDefinitions:
|
195
|
+
Enabled: false
|
196
|
+
Style/GlobalStdStream:
|
226
197
|
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.0
|
data/Gemfile
CHANGED
@@ -3,8 +3,9 @@ source "https://rubygems.org"
|
|
3
3
|
# Specify your gem's dependencies in rakuten_securities.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem "
|
7
|
-
gem "
|
8
|
-
gem "
|
9
|
-
gem "rubocop
|
10
|
-
gem "
|
6
|
+
gem "dotenv", "2.7.6"
|
7
|
+
gem "rake", "13.0.3"
|
8
|
+
gem "rspec", "3.10.0"
|
9
|
+
gem "rubocop", "1.7.0"
|
10
|
+
gem "rubocop-performance", "1.9.1"
|
11
|
+
gem "selenium-webdriver", "3.142.7"
|
data/Gemfile.lock
CHANGED
@@ -1,46 +1,51 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rakuten_securities_scraper (0.1.
|
4
|
+
rakuten_securities_scraper (0.1.7)
|
5
5
|
selenium-webdriver (~> 3.142.7)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
ast (2.4.
|
10
|
+
ast (2.4.2)
|
11
11
|
childprocess (3.0.0)
|
12
|
-
diff-lcs (1.
|
13
|
-
|
14
|
-
parallel (1.
|
15
|
-
parser (
|
16
|
-
ast (~> 2.4.
|
12
|
+
diff-lcs (1.4.4)
|
13
|
+
dotenv (2.7.6)
|
14
|
+
parallel (1.20.1)
|
15
|
+
parser (3.0.0.0)
|
16
|
+
ast (~> 2.4.1)
|
17
17
|
rainbow (3.0.0)
|
18
|
-
rake (
|
18
|
+
rake (13.0.3)
|
19
|
+
regexp_parser (2.0.3)
|
19
20
|
rexml (3.2.4)
|
20
|
-
rspec (3.
|
21
|
-
rspec-core (~> 3.
|
22
|
-
rspec-expectations (~> 3.
|
23
|
-
rspec-mocks (~> 3.
|
24
|
-
rspec-core (3.
|
25
|
-
rspec-support (~> 3.
|
26
|
-
rspec-expectations (3.
|
21
|
+
rspec (3.10.0)
|
22
|
+
rspec-core (~> 3.10.0)
|
23
|
+
rspec-expectations (~> 3.10.0)
|
24
|
+
rspec-mocks (~> 3.10.0)
|
25
|
+
rspec-core (3.10.1)
|
26
|
+
rspec-support (~> 3.10.0)
|
27
|
+
rspec-expectations (3.10.1)
|
27
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
-
rspec-support (~> 3.
|
29
|
-
rspec-mocks (3.
|
29
|
+
rspec-support (~> 3.10.0)
|
30
|
+
rspec-mocks (3.10.1)
|
30
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.
|
32
|
-
rspec-support (3.
|
33
|
-
rubocop (
|
34
|
-
jaro_winkler (~> 1.5.1)
|
32
|
+
rspec-support (~> 3.10.0)
|
33
|
+
rspec-support (3.10.1)
|
34
|
+
rubocop (1.7.0)
|
35
35
|
parallel (~> 1.10)
|
36
|
-
parser (>= 2.7.
|
36
|
+
parser (>= 2.7.1.5)
|
37
37
|
rainbow (>= 2.2.2, < 4.0)
|
38
|
+
regexp_parser (>= 1.8, < 3.0)
|
38
39
|
rexml
|
40
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
39
41
|
ruby-progressbar (~> 1.7)
|
40
42
|
unicode-display_width (>= 1.4.0, < 2.0)
|
41
|
-
rubocop-
|
42
|
-
|
43
|
-
|
43
|
+
rubocop-ast (1.4.1)
|
44
|
+
parser (>= 2.7.1.5)
|
45
|
+
rubocop-performance (1.9.1)
|
46
|
+
rubocop (>= 0.90.0, < 2.0)
|
47
|
+
rubocop-ast (>= 0.4.0)
|
48
|
+
ruby-progressbar (1.11.0)
|
44
49
|
rubyzip (2.3.0)
|
45
50
|
selenium-webdriver (3.142.7)
|
46
51
|
childprocess (>= 0.5, < 4.0)
|
@@ -52,12 +57,13 @@ PLATFORMS
|
|
52
57
|
|
53
58
|
DEPENDENCIES
|
54
59
|
bundler (~> 2.0)
|
55
|
-
|
60
|
+
dotenv (= 2.7.6)
|
61
|
+
rake (= 13.0.3)
|
56
62
|
rakuten_securities_scraper!
|
57
|
-
rspec (
|
58
|
-
rubocop (=
|
59
|
-
rubocop-performance (= 1.
|
63
|
+
rspec (= 3.10.0)
|
64
|
+
rubocop (= 1.7.0)
|
65
|
+
rubocop-performance (= 1.9.1)
|
60
66
|
selenium-webdriver (= 3.142.7)
|
61
67
|
|
62
68
|
BUNDLED WITH
|
63
|
-
2.
|
69
|
+
2.2.4
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require "rakuten_securities_scraper/version"
|
2
2
|
require "selenium-webdriver"
|
3
|
+
require "dotenv/load"
|
3
4
|
|
4
5
|
module RakutenSecuritiesScraper
|
5
6
|
class Error < StandardError; end
|
7
|
+
|
6
8
|
class RakutenScraper
|
7
9
|
def initialize login_id, login_pw
|
8
10
|
@login = {
|
@@ -164,29 +166,30 @@ module RakutenSecuritiesScraper
|
|
164
166
|
end
|
165
167
|
|
166
168
|
def all_history
|
167
|
-
driver = get_selenium_driver(:chrome)
|
169
|
+
@driver = get_selenium_driver(:chrome)
|
168
170
|
wait = Selenium::WebDriver::Wait.new(timeout: 100)
|
169
171
|
url = "https://www.rakuten-sec.co.jp/ITS/V_ACT_Login.html"
|
170
|
-
driver.get url
|
171
|
-
driver.find_element(id: "form-login-id").send_keys @login[:login_id]
|
172
|
-
driver.find_element(id: "form-login-pass").send_keys @login[:login_pw]
|
173
|
-
driver.find_element(id: "login-btn").click
|
174
|
-
wait.until { driver.find_element(id: "header-menu-button-asset") }
|
175
|
-
driver.action.move_to(driver.find_element(id: "header-menu-button-asset")).perform
|
176
|
-
wait.until { driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a") }
|
177
|
-
driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a").click
|
172
|
+
@driver.get url
|
173
|
+
@driver.find_element(id: "form-login-id").send_keys @login[:login_id]
|
174
|
+
@driver.find_element(id: "form-login-pass").send_keys @login[:login_pw]
|
175
|
+
@driver.find_element(id: "login-btn").click
|
176
|
+
wait.until { @driver.find_element(id: "header-menu-button-asset") }
|
177
|
+
@driver.action.move_to(@driver.find_element(id: "header-menu-button-asset")).perform
|
178
|
+
wait.until { @driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a") }
|
179
|
+
@driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a").click
|
178
180
|
|
179
181
|
sleep 3
|
180
|
-
span_select = Selenium::WebDriver::Support::Select.new(driver.find_element(:id, "termCd"))
|
182
|
+
span_select = Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, "termCd"))
|
181
183
|
span_select.select_by(:value, "ALL")
|
182
184
|
|
183
|
-
driver.find_element(css: "input[type='image']").click
|
185
|
+
@driver.find_element(css: "input[type='image']").click
|
184
186
|
sleep 2
|
185
|
-
rows = driver.find_elements(xpath: "//tr")
|
187
|
+
rows = @driver.find_elements(xpath: "//tr")
|
186
188
|
page_num = rows[8].text.scan(/(.+)件中/)[0][0].to_i
|
187
|
-
trade_table_data driver, page_num
|
188
|
-
|
189
|
-
|
189
|
+
trade_table_data @driver, page_num
|
190
|
+
rescue StandardError => e
|
191
|
+
puts e
|
192
|
+
@driver.quit
|
190
193
|
end
|
191
194
|
|
192
195
|
def todays_history
|
@@ -197,7 +200,8 @@ module RakutenSecuritiesScraper
|
|
197
200
|
driver.find_element(id: "form-login-id").send_keys @login[:login_id]
|
198
201
|
driver.find_element(id: "form-login-pass").send_keys @login[:login_pw]
|
199
202
|
driver.find_element(id: "login-btn").click
|
200
|
-
|
203
|
+
sleep 2
|
204
|
+
# wait.until { driver.find_element(id: "header-menu-button-asset") }
|
201
205
|
driver.action.move_to(driver.find_element(id: "header-menu-button-asset")).perform
|
202
206
|
sleep 2
|
203
207
|
wait.until { driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a") }
|
@@ -292,7 +296,7 @@ module RakutenSecuritiesScraper
|
|
292
296
|
# options.add_argument("--ignore-certificate-errors")
|
293
297
|
options.add_argument("--disable-popup-blocking")
|
294
298
|
options.add_argument("--disable-translate")
|
295
|
-
options.add_argument("-headless")
|
299
|
+
# options.add_argument("-headless")
|
296
300
|
Selenium::WebDriver.for :chrome, options: options
|
297
301
|
end
|
298
302
|
end
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.summary = "楽天証券スクレイパー / Rakuten Securities Scraper"
|
10
10
|
spec.description = "This gem is providing scraper methods for everyone to be able to make stock trading applications without writing scraper codes."
|
11
11
|
spec.homepage = "https://github.com/elsoul/rakuten_securities"
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
13
13
|
spec.license = "MIT"
|
14
14
|
spec.metadata["homepage_uri"] = spec.homepage
|
15
15
|
spec.metadata["source_code_uri"] = "https://github.com/elsoul/rakuten_securities_scraper"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rakuten_securities_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FUMI-POPPIN
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- ".gitignore"
|
78
78
|
- ".rspec"
|
79
79
|
- ".rubocop.yml"
|
80
|
+
- ".ruby-version"
|
80
81
|
- ".travis.yml"
|
81
82
|
- Gemfile
|
82
83
|
- Gemfile.lock
|
@@ -95,7 +96,7 @@ metadata:
|
|
95
96
|
homepage_uri: https://github.com/elsoul/rakuten_securities
|
96
97
|
source_code_uri: https://github.com/elsoul/rakuten_securities_scraper
|
97
98
|
changelog_uri: https://github.com/elsoul/rakuten_securities_scraper
|
98
|
-
post_install_message:
|
99
|
+
post_install_message:
|
99
100
|
rdoc_options: []
|
100
101
|
require_paths:
|
101
102
|
- lib
|
@@ -103,15 +104,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
104
|
requirements:
|
104
105
|
- - ">="
|
105
106
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
107
|
+
version: 3.0.0
|
107
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
109
|
requirements:
|
109
110
|
- - ">="
|
110
111
|
- !ruby/object:Gem::Version
|
111
112
|
version: '0'
|
112
113
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
114
|
-
signing_key:
|
114
|
+
rubygems_version: 3.2.4
|
115
|
+
signing_key:
|
115
116
|
specification_version: 4
|
116
117
|
summary: 楽天証券スクレイパー / Rakuten Securities Scraper
|
117
118
|
test_files: []
|