SetAllStock 0.0.1

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/SetAllStock.rb +35 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8ed6616c6e3c017619d2236462fc94673043c912837d2041292fcdeddbffbfcb
4
+ data.tar.gz: a9e4f25eb43559444963d54ba7b4dfd01d2addc9e18d70f9acedc18a90a3cf75
5
+ SHA512:
6
+ metadata.gz: f1f411f1f6f708a09048d3783c1cfdc51c7855b96eff61d578ab24cb8806680ff3ff4208ac3dfa004c6da306b6072a172397d812f6709484d8169da29fc7329f
7
+ data.tar.gz: 55d2ad3bf7a2e9711d3a8932046e8dba8270796beb13d0ef306548c31f42cd7969d53a2a9aa6751f8ad24a13ed6c4a316df912c70c4c6d5f53394a5031aadf16
@@ -0,0 +1,35 @@
1
+ # 6210545734 Puvana Swatvanith SKE17
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'nokogiri'
5
+
6
+ module Set_All_Stock
7
+ class SetAllStock
8
+ def self.display?
9
+ all_prefix = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
10
+ base_url = 'https://www.set.or.th/set/commonslookup.do?language=th&country=TH&prefix='
11
+ base_url_company = 'https://www.set.or.th'
12
+
13
+ (0..all_prefix.length - 1).each do |i|
14
+ current_url = base_url + all_prefix[i]
15
+ current_source = Net::HTTP.get(URI.parse(current_url))
16
+ current_doc = Nokogiri::HTML(current_source)
17
+ a_in_table = current_doc.css('table.table-profile.table-hover.table-set-border-yellow').css('a')
18
+ all_link = a_in_table.map { |element| element['href'] }.compact
19
+
20
+ all_link.each do |link|
21
+ link['companyprofile'] = 'companyhighlight'
22
+ link['PageId=4'] = 'PageId=5'
23
+ # puts base_url_company + link
24
+ company_source = Net::HTTP.get(URI.parse(base_url_company + link))
25
+ company_doc = Nokogiri::HTML(company_source)
26
+ all_td_in_table = company_doc.css('div.table-responsive').css('table.table-hover.table-info').css('tbody')
27
+ money_line = all_td_in_table.css('td')[6].inner_html
28
+ money_line = all_td_in_table.css('td')[4].inner_html if money_line == 'หนี้สินรวม'
29
+ company_name = company_doc.css('div.col-xs-12.col-md-12.col-lg-8').css('h3').to_s
30
+ print company_name[4, company_name.length - 9], ' : ', money_line, "\n"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: SetAllStock
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Puvana 6210545734 SKE17
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple SET market display all stock
14
+ email: puvana.jp36@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/SetAllStock.rb
20
+ homepage: https://rubygems.org/gems/SetAllStock
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.4
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: SET all stock!
43
+ test_files: []