stockbot 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/stockbot.rb +40 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a3fa1f22a55254782c305ace2e2e703f6a6f1660827ee0a3b65a391dbe4bd3b1
4
+ data.tar.gz: a49fab6e89a10e24b583ab5c991c4a917c62946962b7aba457722079a1202fbf
5
+ SHA512:
6
+ metadata.gz: 756464a87eab0f3857abc063437f64f81fe5917970a4c9554027419793a260b95d5eff155715c734f154b07835a49f6b46c024edfbfd6e1ef1068b4812eaa626
7
+ data.tar.gz: 239da47b1d73625a4c493e6be086c71618e8d7f5b32f74161cb9448c688909fd3fbfe352cc714ec3398540868293ab30ffa19a80de0eddd6e798cfa14afd90df
data/lib/stockbot.rb ADDED
@@ -0,0 +1,40 @@
1
+ # Anusid Wachiracharoenwong
2
+ # 6201546714
3
+
4
+ require 'open-uri'
5
+ require 'nokogiri'
6
+
7
+ class Stockbot
8
+
9
+ def self.showinfo
10
+
11
+ prefix = ['NUMBER',*'a'..'z']
12
+
13
+ prefix.each do |e|
14
+ html = URI.open("https://www.set.or.th/set/commonslookup.do?prefix=#{e}")
15
+ response = Nokogiri::HTML(html)
16
+
17
+
18
+ response.css("tr td a").each do |x|
19
+ detail_url = 'https://www.set.or.th' + x["href"]
20
+ detail_page = URI.open(detail_url)
21
+ detail = Nokogiri::HTML(detail_page)
22
+ name = detail.css("div h3").text
23
+
24
+ # get assests
25
+ detail_url["profile"] = "highlight"
26
+ assests_page = URI.open(detail_url)
27
+ assests = Nokogiri::HTML(assests_page)
28
+ lastest_assests = assests.css("#maincontent > div > div.table-responsive > table > tbody:nth-child(3) > tr:nth-child(2) > td:nth-last-child(-n+2)").text
29
+
30
+ unless !lastest_assests.strip.empty?
31
+ lastest_assests = assests.css("#maincontent > div > div.table-responsive > table > tbody:nth-child(3) > tr:nth-child(2) > td:nth-last-child(-n+2)").text
32
+ end
33
+
34
+ puts "#{name} : #{lastest_assests}"
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stockbot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Anusid Wachiracharoenwong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: 'Scrap company name and total assests from SET '
14
+ email: taeinspiration@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/stockbot.rb
20
+ homepage: http://rubygems.org/gems/stockbot
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.1.2
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Get data from SET
43
+ test_files: []