rakuten_securities_scraper 0.1.0
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 +7 -0
- data/.gitignore +29 -0
- data/.rspec +3 -0
- data/.rubocop.yml +219 -0
- data/.travis.yml +6 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +61 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rakuten_securities_scraper.rb +136 -0
- data/lib/rakuten_securities_scraper/version.rb +3 -0
- data/rakuten_securities_scraper.gemspec +26 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4597241d08e13fa2afc21854b6bef9a2948633244b7fd19355f55e63a891fc7d
|
4
|
+
data.tar.gz: 3ff338627402785d5d992f3de6eb8356306b956e2958cdf3afe5498e43cb4e0b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bfbc83f71accbf4fd07eb0aefb4665fe937d41780e7a8491f227424431f026d96e6c4c1da78363a5d1418cbe09fa3ab489fc6c6b6e0a402cfeeaaad0dbc7a043
|
7
|
+
data.tar.gz: 061317f5fe6878f06b43b1fe6988ec63cd95457cefa447568479fdf68d794f8e4ebf87ce20d71913806d609766a4b5f4e44b547548720daea3488d2ede437942
|
data/.gitignore
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
/.bundle
|
10
|
+
/.secret_key
|
11
|
+
/.secret-key
|
12
|
+
/.envrc
|
13
|
+
/.vscode
|
14
|
+
/log/*
|
15
|
+
/tmp/*
|
16
|
+
!/log/.keep
|
17
|
+
!/tmp/.keep
|
18
|
+
/shared/certs/*
|
19
|
+
.DS_Store
|
20
|
+
/db/.DS_Store
|
21
|
+
/config/.DS_Store
|
22
|
+
/storage/*
|
23
|
+
!/storage/.keep
|
24
|
+
/lib/json/*
|
25
|
+
.byebug_history
|
26
|
+
/.idea/
|
27
|
+
/cloud_sql_proxy
|
28
|
+
# rspec failure tracking
|
29
|
+
.rspec_status
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
AllCops:
|
2
|
+
EnabledByDefault: true
|
3
|
+
|
4
|
+
##################### Style ##################################
|
5
|
+
|
6
|
+
# redirect_to xxx and return のイディオムを維持したい
|
7
|
+
Style/AndOr:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
# 日本語のコメントを許可する
|
11
|
+
Style/AsciiComments:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Style/SymbolArray:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Style/WordArray:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Style/MixinGrouping:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Style/RescueStandardError:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Style/MethodCallWithArgsParentheses:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Style/DocumentationMethod:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/CollectionMethods:
|
33
|
+
PreferredMethods:
|
34
|
+
detect: "detect"
|
35
|
+
find: "detect"
|
36
|
+
inject: "inject"
|
37
|
+
reduce: "inject"
|
38
|
+
|
39
|
+
# ドキュメントの無い public class を許可する
|
40
|
+
Style/Documentation:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
# !! のイディオムは積極的に使う
|
44
|
+
Style/DoubleNegation:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
# MethodDefParentheses:
|
48
|
+
# EnforcedStyle: require_no_parentheses
|
49
|
+
|
50
|
+
# メソッドチェーンの改行は末尾に . を入れる
|
51
|
+
# REPL に貼り付けた際の暴発を防ぐため
|
52
|
+
Layout/DotPosition:
|
53
|
+
EnforcedStyle: trailing
|
54
|
+
|
55
|
+
|
56
|
+
Layout/EmptyLineAfterGuardClause:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
# 明示的に else で nil を返すのは分かりやすいので許可する
|
60
|
+
Style/EmptyElse:
|
61
|
+
EnforcedStyle: empty
|
62
|
+
|
63
|
+
# 桁揃えが綺麗にならないことが多いので migration は除外
|
64
|
+
Layout/ExtraSpacing:
|
65
|
+
Exclude:
|
66
|
+
- "db/migrate/*.rb"
|
67
|
+
|
68
|
+
# いずれかに揃えるのならば `sprintf` や `format` より String#% が好きです
|
69
|
+
Style/FormatString:
|
70
|
+
EnforcedStyle: percent
|
71
|
+
|
72
|
+
# if 文の中に 3 行程度のブロックを書くぐらいは許容した方が現実的
|
73
|
+
Style/GuardClause:
|
74
|
+
MinBodyLength: 5
|
75
|
+
|
76
|
+
# rake タスクの順序の hash は rocket を許可する
|
77
|
+
Style/HashSyntax:
|
78
|
+
EnforcedStyle: ruby19
|
79
|
+
Exclude:
|
80
|
+
- "**/*.rake"
|
81
|
+
- "Rakefile"
|
82
|
+
|
83
|
+
# 条件式の方を意識させたい場合には後置の if/unless を使わない方が分かりやすい
|
84
|
+
Style/IfUnlessModifier:
|
85
|
+
Enabled: false
|
86
|
+
|
87
|
+
# private/protected は一段深くインデントする
|
88
|
+
Style/PreferredHashMethods:
|
89
|
+
EnforcedStyle: short
|
90
|
+
|
91
|
+
# scope 等は複数行でも lambda ではなく ->{} で揃えた方が見た目が綺麗
|
92
|
+
Style/Lambda:
|
93
|
+
Enabled: false
|
94
|
+
|
95
|
+
# 1_000_000 と区切り文字が 2 個以上必要になる場合のみ _ 区切りを必須にする
|
96
|
+
Style/NumericLiterals:
|
97
|
+
MinDigits: 7
|
98
|
+
|
99
|
+
# 正規表現にマッチさせた時の特殊変数の置き換えは Regex.last_match ではなく
|
100
|
+
# 名前付きキャプチャを使って参照したいので auto-correct しない
|
101
|
+
Style/PerlBackrefs:
|
102
|
+
AutoCorrect: false
|
103
|
+
|
104
|
+
# 特に model 内において、ローカル変数とメソッド呼び出しの区別をつけた方が分かりやすい場合が多い
|
105
|
+
Style/RedundantSelf:
|
106
|
+
Enabled: false
|
107
|
+
|
108
|
+
Style/FrozenStringLiteralComment:
|
109
|
+
Enabled: false
|
110
|
+
|
111
|
+
# 受け取り側で multiple assignment しろというのを明示
|
112
|
+
Style/RedundantReturn:
|
113
|
+
AllowMultipleReturnValues: true
|
114
|
+
|
115
|
+
# spec 内は見た目が綺麗になるので許可
|
116
|
+
Style/Semicolon:
|
117
|
+
Exclude:
|
118
|
+
- "spec/**/*"
|
119
|
+
|
120
|
+
# fail と使い分ける必要ナシ
|
121
|
+
Style/SignalException:
|
122
|
+
EnforcedStyle: only_raise
|
123
|
+
|
124
|
+
Style/MethodDefParentheses:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
# `||` も align に使うことがあるので追加する
|
128
|
+
# Style/SpaceAroundOperators:
|
129
|
+
# MultiSpaceAllowedForOperators:
|
130
|
+
# - "="
|
131
|
+
# - "=>"
|
132
|
+
# - "||"
|
133
|
+
|
134
|
+
# * 式展開したい場合に書き換えるのが面倒
|
135
|
+
# * 文章ではダブルクォートよりもシングルクォートの方が頻出する
|
136
|
+
# ことから EnforcedStyle: double_quotes 推奨
|
137
|
+
Style/StringLiterals:
|
138
|
+
EnforcedStyle: double_quotes
|
139
|
+
|
140
|
+
# auto-correct 時に Style/StringLiterals とカニバって無限ループになる (v0.28.0)
|
141
|
+
Style/StringLiteralsInInterpolation:
|
142
|
+
Enabled: false
|
143
|
+
|
144
|
+
# いくらなんでも inject { |a, e| } は短すぎるので分かりやすい名前をつけたい
|
145
|
+
Style/SingleLineBlockParams:
|
146
|
+
Enabled: false
|
147
|
+
|
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
|
+
Lint/UnderscorePrefixedVariableName:
|
163
|
+
Enabled: false
|
164
|
+
|
165
|
+
# 子クラスで実装させるつもりのメソッドで引っかかるので
|
166
|
+
Lint/UnusedMethodArgument:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
##################### Metrics ##################################
|
170
|
+
|
171
|
+
Metrics/AbcSize:
|
172
|
+
Enabled: false
|
173
|
+
|
174
|
+
# 6 は強すぎるので緩める
|
175
|
+
Metrics/CyclomaticComplexity:
|
176
|
+
Max: 10
|
177
|
+
|
178
|
+
Metrics/PerceivedComplexity:
|
179
|
+
Enabled: false
|
180
|
+
|
181
|
+
Metrics/BlockLength:
|
182
|
+
Enabled: false
|
183
|
+
|
184
|
+
Layout/LineLength:
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
|
188
|
+
Metrics/MethodLength:
|
189
|
+
Enabled: false
|
190
|
+
|
191
|
+
Metrics/ClassLength:
|
192
|
+
Enabled: false
|
193
|
+
|
194
|
+
Naming/HeredocDelimiterNaming:
|
195
|
+
Enabled: false
|
196
|
+
|
197
|
+
Naming/AccessorMethodName:
|
198
|
+
Enabled: false
|
199
|
+
|
200
|
+
Metrics/ModuleLength:
|
201
|
+
Enabled: false
|
202
|
+
|
203
|
+
Lint/UnusedBlockArgument:
|
204
|
+
Enabled: false
|
205
|
+
|
206
|
+
Lint/RescueException:
|
207
|
+
Enabled: false
|
208
|
+
|
209
|
+
Naming/RescuedExceptionsVariableName:
|
210
|
+
Enabled: false
|
211
|
+
|
212
|
+
Bundler/GemComment:
|
213
|
+
Enabled: false
|
214
|
+
|
215
|
+
Style/SafeNavigation:
|
216
|
+
Enabled: false
|
217
|
+
|
218
|
+
Lint/NumberConversion:
|
219
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rakuten_securities_scraper (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
childprocess (3.0.0)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
jaro_winkler (1.5.4)
|
13
|
+
parallel (1.19.1)
|
14
|
+
parser (2.7.1.2)
|
15
|
+
ast (~> 2.4.0)
|
16
|
+
rainbow (3.0.0)
|
17
|
+
rake (12.3.3)
|
18
|
+
rexml (3.2.4)
|
19
|
+
rspec (3.9.0)
|
20
|
+
rspec-core (~> 3.9.0)
|
21
|
+
rspec-expectations (~> 3.9.0)
|
22
|
+
rspec-mocks (~> 3.9.0)
|
23
|
+
rspec-core (3.9.2)
|
24
|
+
rspec-support (~> 3.9.3)
|
25
|
+
rspec-expectations (3.9.2)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.9.0)
|
28
|
+
rspec-mocks (3.9.1)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.9.0)
|
31
|
+
rspec-support (3.9.3)
|
32
|
+
rubocop (0.82.0)
|
33
|
+
jaro_winkler (~> 1.5.1)
|
34
|
+
parallel (~> 1.10)
|
35
|
+
parser (>= 2.7.0.1)
|
36
|
+
rainbow (>= 2.2.2, < 4.0)
|
37
|
+
rexml
|
38
|
+
ruby-progressbar (~> 1.7)
|
39
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
40
|
+
rubocop-performance (1.5.2)
|
41
|
+
rubocop (>= 0.71.0)
|
42
|
+
ruby-progressbar (1.10.1)
|
43
|
+
rubyzip (2.3.0)
|
44
|
+
selenium-webdriver (3.142.7)
|
45
|
+
childprocess (>= 0.5, < 4.0)
|
46
|
+
rubyzip (>= 1.2.2)
|
47
|
+
unicode-display_width (1.7.0)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
rake (~> 12.0)
|
54
|
+
rakuten_securities_scraper!
|
55
|
+
rspec (~> 3.0)
|
56
|
+
rubocop (= 0.82.0)
|
57
|
+
rubocop-performance (= 1.5.2)
|
58
|
+
selenium-webdriver (= 3.142.7)
|
59
|
+
|
60
|
+
BUNDLED WITH
|
61
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# RakutenSecuritiesScraper
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rakuten_securities_scraper`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'rakuten_securities_scraper'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rakuten_securities_scraper
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rakuten_securities_scraper.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rakuten_securities_scraper"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require "rakuten_securities_scraper/version"
|
2
|
+
|
3
|
+
module RakutenSecuritiesScraper
|
4
|
+
class Error < StandardError; end
|
5
|
+
class RakutenScraper
|
6
|
+
def initialize login_id, login_pw
|
7
|
+
@login = {
|
8
|
+
login_id: login_id,
|
9
|
+
login_pw: login_pw
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def all_history
|
14
|
+
driver = get_selenium_driver(:chrome)
|
15
|
+
wait = Selenium::WebDriver::Wait.new(timeout: 100)
|
16
|
+
url = "https://www.rakuten-sec.co.jp/ITS/V_ACT_Login.html"
|
17
|
+
driver.get url
|
18
|
+
driver.find_element(id: "form-login-id").send_keys @login[:login_id]
|
19
|
+
driver.find_element(id: "form-login-pass").send_keys @login[:login_pw]
|
20
|
+
driver.find_element(id: "login-btn").click
|
21
|
+
wait.until { driver.find_element(id: "header-menu-button-asset") }
|
22
|
+
driver.action.move_to(driver.find_element(id: "header-menu-button-asset")).perform
|
23
|
+
wait.until { driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a") }
|
24
|
+
driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a").click
|
25
|
+
|
26
|
+
sleep 3
|
27
|
+
span_select = Selenium::WebDriver::Support::Select.new(driver.find_element(:id, "termCd"))
|
28
|
+
span_select.select_by(:value, "ALL")
|
29
|
+
|
30
|
+
driver.find_element(css: "input[type='image']").click
|
31
|
+
sleep 2
|
32
|
+
rows = driver.find_elements(xpath: "//tr")
|
33
|
+
page_num = rows[8].text.scan(/(.+)件中/)[0][0].to_i
|
34
|
+
trade_table_data driver, page_num
|
35
|
+
end
|
36
|
+
|
37
|
+
def todays_history
|
38
|
+
driver = get_selenium_driver(:chrome)
|
39
|
+
wait = Selenium::WebDriver::Wait.new(timeout: 100)
|
40
|
+
url = "https://www.rakuten-sec.co.jp/ITS/V_ACT_Login.html"
|
41
|
+
driver.get url
|
42
|
+
driver.find_element(id: "form-login-id").send_keys @login[:login_id]
|
43
|
+
driver.find_element(id: "form-login-pass").send_keys @login[:login_pw]
|
44
|
+
driver.find_element(id: "login-btn").click
|
45
|
+
wait.until { driver.find_element(id: "header-menu-button-asset") }
|
46
|
+
driver.action.move_to(driver.find_element(id: "header-menu-button-asset")).perform
|
47
|
+
wait.until { driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a") }
|
48
|
+
driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a").click
|
49
|
+
|
50
|
+
driver.find_element(css: "input[type='image']").click
|
51
|
+
sleep 2
|
52
|
+
rows = driver.find_elements(xpath: "//tr")
|
53
|
+
begin
|
54
|
+
page_num = rows[8].text.scan(/(.+)件中/)[0][0].to_i
|
55
|
+
rescue
|
56
|
+
return "no data"
|
57
|
+
end
|
58
|
+
trade_table_data driver, page_num
|
59
|
+
end
|
60
|
+
|
61
|
+
def trade_table_data driver, page_num
|
62
|
+
run_times = page_num.divmod(20)
|
63
|
+
trade_records = []
|
64
|
+
(1..run_times[0]-1).each do |f|
|
65
|
+
rows = driver.find_elements(xpath: "//tr")
|
66
|
+
rows[10..29].map do |row|
|
67
|
+
cells = row.find_elements(:css, "td").map { |a| a.text.strip.gsub(",", "") }
|
68
|
+
trade_records << {
|
69
|
+
bit_date: cells[0].split("\n")[0],
|
70
|
+
gain_date: cells[0].split("\n")[1],
|
71
|
+
stock_name: cells[1].split("\n")[0],
|
72
|
+
code: cells[1].split("\n")[1].split(" ")[0],
|
73
|
+
market: cells[1].split("\n")[1].split(" ")[1],
|
74
|
+
account: cells[2],
|
75
|
+
trade_type: cells[3].split("\n")[0],
|
76
|
+
buy_sell: cells[3].split("\n")[1],
|
77
|
+
credit: cells[4].split("\n")[0],
|
78
|
+
due: cells[4].split("\n")[1],
|
79
|
+
stocks: cells[5].split("\n")[0].gsub(" 株", ""),
|
80
|
+
price: cells[5].split("\n")[1],
|
81
|
+
fee: cells[6].split("\n")[0],
|
82
|
+
tax: cells[6].split("\n")[1],
|
83
|
+
charge: cells[7].split("\n")[0],
|
84
|
+
tax_type: cells[7].split("\n")[1],
|
85
|
+
total_price: cells[8]
|
86
|
+
}
|
87
|
+
return trade_records if page_num < 20
|
88
|
+
end
|
89
|
+
driver.find_element(link: "次の20件").click
|
90
|
+
end
|
91
|
+
sleep 2
|
92
|
+
driver.find_element(link: "次の#{run_times[1]}件").click
|
93
|
+
rows = driver.find_elements(xpath: "//tr")
|
94
|
+
rows[10.."1#{run_times[1]}".to_i-1].map do |row|
|
95
|
+
cells = row.find_elements(:css, "td").map { |a| a.text.strip.gsub(",", "") }
|
96
|
+
trade_records << {
|
97
|
+
bit_date: cells[0].split("\n")[0],
|
98
|
+
gain_date: cells[0].split("\n")[1],
|
99
|
+
stock_name: cells[1].split("\n")[0],
|
100
|
+
code: cells[1].split("\n")[1].split(" ")[0],
|
101
|
+
market: cells[1].split("\n")[1].split(" ")[1],
|
102
|
+
account: cells[2],
|
103
|
+
trade_type: cells[3].split("\n")[0],
|
104
|
+
buy_sell: cells[3].split("\n")[1],
|
105
|
+
credit: cells[4].split("\n")[0],
|
106
|
+
due: cells[4].split("\n")[1],
|
107
|
+
stocks: cells[5].split("\n")[0].gsub(" 株", ""),
|
108
|
+
price: cells[5].split("\n")[1],
|
109
|
+
fee: cells[6].split("\n")[0],
|
110
|
+
tax: cells[6].split("\n")[1],
|
111
|
+
charge: cells[7].split("\n")[0],
|
112
|
+
tax_type: cells[7].split("\n")[1],
|
113
|
+
total_price: cells[8]
|
114
|
+
}
|
115
|
+
end
|
116
|
+
trade_records
|
117
|
+
end
|
118
|
+
|
119
|
+
def get_selenium_driver(mode = :chrome)
|
120
|
+
case mode
|
121
|
+
when :firefox_remote_capabilities
|
122
|
+
firefox_capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
|
123
|
+
Selenium::WebDriver.for(:remote, url: "http://hub:4444/wd/hub", desired_capabilities: firefox_capabilities)
|
124
|
+
when :firefox
|
125
|
+
Selenium::WebDriver.for :firefox
|
126
|
+
else
|
127
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
128
|
+
# options.add_argument("--ignore-certificate-errors")
|
129
|
+
options.add_argument("--disable-popup-blocking")
|
130
|
+
options.add_argument("--disable-translate")
|
131
|
+
options.add_argument("-headless")
|
132
|
+
Selenium::WebDriver.for :chrome, options: options
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative "lib/rakuten_securities_scraper/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "rakuten_securities_scraper"
|
5
|
+
spec.version = RakutenSecuritiesScraper::VERSION
|
6
|
+
spec.authors = ["FUMI-POPPIN"]
|
7
|
+
spec.email = ["fumitake.kawasaki@el-soul.com"]
|
8
|
+
|
9
|
+
spec.summary = "楽天証券スクレイパー / Rakuten Securities Scraper"
|
10
|
+
spec.description = "楽天証券スクレイパー / Rakuten Securities Scraper"
|
11
|
+
spec.homepage = "https://github.com/elsoul/rakuten_securities"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
+
spec.metadata["source_code_uri"] = "https://github.com/elsoul/rakuten_securities_scraper"
|
16
|
+
spec.metadata["changelog_uri"] = "https://github.com/elsoul/rakuten_securities_scraper"
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files =
|
20
|
+
Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rakuten_securities_scraper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- FUMI-POPPIN
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: 楽天証券スクレイパー / Rakuten Securities Scraper
|
14
|
+
email:
|
15
|
+
- fumitake.kawasaki@el-soul.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- ".rspec"
|
22
|
+
- ".rubocop.yml"
|
23
|
+
- ".travis.yml"
|
24
|
+
- Gemfile
|
25
|
+
- Gemfile.lock
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/console
|
29
|
+
- bin/setup
|
30
|
+
- lib/rakuten_securities_scraper.rb
|
31
|
+
- lib/rakuten_securities_scraper/version.rb
|
32
|
+
- rakuten_securities_scraper.gemspec
|
33
|
+
homepage: https://github.com/elsoul/rakuten_securities
|
34
|
+
licenses:
|
35
|
+
- MIT
|
36
|
+
metadata:
|
37
|
+
homepage_uri: https://github.com/elsoul/rakuten_securities
|
38
|
+
source_code_uri: https://github.com/elsoul/rakuten_securities_scraper
|
39
|
+
changelog_uri: https://github.com/elsoul/rakuten_securities_scraper
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.7.0
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubygems_version: 3.1.3
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: 楽天証券スクレイパー / Rakuten Securities Scraper
|
59
|
+
test_files: []
|