rakuten_securities_scraper 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/Gemfile.lock +1 -1
- data/LICENSE +21 -0
- data/README.md +32 -1
- data/lib/rakuten_securities_scraper.rb +70 -3
- data/lib/rakuten_securities_scraper/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5f91840ce280a6f2219a4b556fde59c2feb73aea9c0d78c2636c67f76090c09
|
4
|
+
data.tar.gz: b779046723e8a50f388892bc5a662b249591e20688d3f0ecb8c2f01de9b6f02b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d455f3b999e60d33c1205c997eb6032679f21fc407a316d57c20478080eb0d494336f2226d620bd3a6b1bdb4cce2b2f1b8554f39b353ad7a2a971c4b6592ee37
|
7
|
+
data.tar.gz: a28fba136216b41220913abe42febaff9cc17f4250257589d285e9b246affb56abe2842209a4f4dfe5adc9063f3eeb1cbce1037df2efd352110d4c0bf806dc32
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 ELSOUL
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,8 +1,37 @@
|
|
1
|
+
[![RakutenSecuritiesScraper](https://firebasestorage.googleapis.com/v0/b/el-quest.appspot.com/o/mediaLibrary%2F1589293505170_rakuten-shoken.jpg?alt=media&token=f86b6870-fd3f-42aa-805d-db35cb53a9b6)](https://www.rakuten-sec.co.jp/)
|
2
|
+
|
3
|
+
<p align="center">
|
4
|
+
|
5
|
+
<a aria-label="Ruby logo" href="https://el-soul.com">
|
6
|
+
<img src="https://badgen.net/badge/icon/Made%20by%20ELSOUL?icon=ruby&label&color=black&labelColor=black">
|
7
|
+
</a>
|
8
|
+
<br/>
|
9
|
+
|
10
|
+
<a aria-label="Ruby Gem version" href="https://rubygems.org/gems/rakuten_securities_scraper">
|
11
|
+
<img alt="" src="https://badgen.net/rubygems/v/rakuten_securities_scraper/latest">
|
12
|
+
</a>
|
13
|
+
<a aria-label="Downloads Number" href="https://rubygems.org/gems/rakuten_securities_scraper">
|
14
|
+
<img alt="" src="https://badgen.net/rubygems/dt/rakuten_securities_scraper">
|
15
|
+
</a>
|
16
|
+
<a aria-label="License" href="https://github.com/elsoul/rakuten_securities_scraper/blob/master/LICENSE">
|
17
|
+
<img alt="" src="https://badgen.net/badge/license/MIT/blue">
|
18
|
+
</a>
|
19
|
+
</p>
|
20
|
+
|
1
21
|
# RakutenSecuritiesScraper
|
2
22
|
|
3
23
|
Rakuten Securities Scraper / 楽天証券スクレイパー
|
24
|
+
|
25
|
+
## Introduction
|
26
|
+
|
4
27
|
This gem is providing scraper methods for everyone to be able to make stock trading applications without writing scraper codes.
|
5
28
|
|
29
|
+
It features:
|
30
|
+
|
31
|
+
- Get all trading histories
|
32
|
+
- Auto Buying (future)
|
33
|
+
- Auto Selling (future)
|
34
|
+
|
6
35
|
## Installation
|
7
36
|
|
8
37
|
Add this line to your application's Gemfile:
|
@@ -31,6 +60,9 @@ Or install it yourself as:
|
|
31
60
|
## Get All Trade History
|
32
61
|
puts data.all_history
|
33
62
|
|
63
|
+
## Get Today's Executed Order
|
64
|
+
puts data.todays_order
|
65
|
+
|
34
66
|
```
|
35
67
|
|
36
68
|
## Development
|
@@ -42,4 +74,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
42
74
|
## Contributing
|
43
75
|
|
44
76
|
Bug reports and pull requests are welcome on GitHub at https://github.com/elsoul/rakuten_securities_scraper.
|
45
|
-
|
@@ -11,6 +11,66 @@ module RakutenSecuritiesScraper
|
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
14
|
+
def todays_transaction
|
15
|
+
driver = get_selenium_driver(:chrome)
|
16
|
+
wait = Selenium::WebDriver::Wait.new(timeout: 100)
|
17
|
+
url = "https://www.rakuten-sec.co.jp/ITS/V_ACT_Login.html"
|
18
|
+
driver.get url
|
19
|
+
driver.find_element(id: "form-login-id").send_keys @login[:login_id]
|
20
|
+
driver.find_element(id: "form-login-pass").send_keys @login[:login_pw]
|
21
|
+
driver.find_element(id: "login-btn").click
|
22
|
+
sleep 2
|
23
|
+
driver.action.move_to(driver.find_element(id: "gmenu_domestic_stock")).perform
|
24
|
+
sleep 2
|
25
|
+
driver.find_element(id: "gmenu_domestic_stock").click
|
26
|
+
sleep 2
|
27
|
+
driver.find_element(id: "nav-sub-menu-order-arrow").click
|
28
|
+
wait.until { driver.find_element(xpath: "//*[@id='str-main-inner']/table/tbody/tr/td/form/div[2]/div/ul/li[3]/a") }
|
29
|
+
driver.find_element(xpath: "//*[@id='str-main-inner']/table/tbody/tr/td/form/div[2]/div/ul/li[3]/a").click
|
30
|
+
sleep 2
|
31
|
+
span_select = Selenium::WebDriver::Support::Select.new(driver.find_element(:id, "orderStatus"))
|
32
|
+
span_select.select_by(:value, "5")
|
33
|
+
sleep 1
|
34
|
+
driver.find_element(css: "input[type='image']").click
|
35
|
+
sleep 2
|
36
|
+
tables = driver.find_elements(xpath: "//tr")
|
37
|
+
page_num = driver.find_element(class_name: "mtext").text.scan(/(.+)件中/)[0][0].to_i
|
38
|
+
row_nums = (21..(21 + (page_num * 3) -1)).to_a
|
39
|
+
records = []
|
40
|
+
row_nums.each_slice(3).to_a.map do |col_num|
|
41
|
+
detail = {}
|
42
|
+
tables[col_num[0]..col_num[2]].map.with_index do |row, i|
|
43
|
+
cells = row.find_elements(:css, "td").map(&:text)
|
44
|
+
case i
|
45
|
+
when 0
|
46
|
+
detail[:order_id] = cells[0] if cells[0]
|
47
|
+
detail[:order_status] = cells[1] if cells[1]
|
48
|
+
detail[:order_date] = cells[2] if cells[2]
|
49
|
+
detail[:stock_name] = cells[3].split("\n")[0] if cells[3]
|
50
|
+
detail[:code] = cells[3].split("\n")[1].split(" ")[0] if cells[3]
|
51
|
+
detail[:market] = cells[3].split("\n")[1].split(" ")[1] if cells[3]
|
52
|
+
detail[:trade_type] = cells[4] if cells[4]
|
53
|
+
detail[:buy_sell] = cells[5] if cells[5]
|
54
|
+
detail[:order_amount] = cells[7] if cells[7]
|
55
|
+
detail[:unit_price] = cells[8] if cells[8]
|
56
|
+
detail[:executed_price] = cells[8] if cells[8]
|
57
|
+
when 1
|
58
|
+
detail[:order_condition] = cells[2] if cells[2]
|
59
|
+
detail[:account_type] = cells[3] if cells[3]
|
60
|
+
detail[:executed_price] = cells[5] if cells[5]
|
61
|
+
detail[:fee] = cells[6] if cells[6]
|
62
|
+
else
|
63
|
+
detail[:order_expire_date] = cells[2] if cells[2]
|
64
|
+
detail[:order_type] = cells[3] if cells[3]
|
65
|
+
end
|
66
|
+
records << detail
|
67
|
+
end
|
68
|
+
end
|
69
|
+
records
|
70
|
+
ensure
|
71
|
+
driver.quit
|
72
|
+
end
|
73
|
+
|
14
74
|
def all_history
|
15
75
|
driver = get_selenium_driver(:chrome)
|
16
76
|
wait = Selenium::WebDriver::Wait.new(timeout: 100)
|
@@ -47,9 +107,11 @@ module RakutenSecuritiesScraper
|
|
47
107
|
driver.find_element(id: "login-btn").click
|
48
108
|
wait.until { driver.find_element(id: "header-menu-button-asset") }
|
49
109
|
driver.action.move_to(driver.find_element(id: "header-menu-button-asset")).perform
|
110
|
+
sleep 2
|
50
111
|
wait.until { driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a") }
|
112
|
+
sleep 2
|
51
113
|
driver.find_element(xpath: "/html/body/div[2]/div/div/div[2]/ul[1]/li[1]/ul/li[1]/a").click
|
52
|
-
|
114
|
+
sleep 3
|
53
115
|
driver.find_element(css: "input[type='image']").click
|
54
116
|
sleep 2
|
55
117
|
rows = driver.find_elements(xpath: "//tr")
|
@@ -89,12 +151,17 @@ module RakutenSecuritiesScraper
|
|
89
151
|
tax_type: cells[7].split("\n")[1],
|
90
152
|
total_price: cells[8]
|
91
153
|
}
|
92
|
-
return trade_records if page_num < 20
|
93
154
|
end
|
155
|
+
puts trade_records
|
156
|
+
return trade_records if page_num < 20
|
94
157
|
driver.find_element(link: "次の20件").click
|
95
158
|
end
|
96
159
|
sleep 2
|
97
|
-
|
160
|
+
begin
|
161
|
+
driver.find_element(link: "次の#{run_times[1]}件").click
|
162
|
+
rescue
|
163
|
+
return trade_records
|
164
|
+
end
|
98
165
|
rows = driver.find_elements(xpath: "//tr")
|
99
166
|
rows[10.."1#{run_times[1]}".to_i-1].map do |row|
|
100
167
|
cells = row.find_elements(:css, "td").map { |a| a.text.strip.gsub(",", "") }
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FUMI-POPPIN
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem is providing scraper methods for everyone to be able to make
|
14
14
|
stock trading applications without writing scraper codes.
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- ".travis.yml"
|
25
25
|
- Gemfile
|
26
26
|
- Gemfile.lock
|
27
|
+
- LICENSE
|
27
28
|
- README.md
|
28
29
|
- Rakefile
|
29
30
|
- bin/console
|