strock_bot 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/strock_bot.rb +38 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3884cc68eddb1c5edbee2ea7a2ba2e87a0e59aa684090a3b4116176e05d50131
4
+ data.tar.gz: 267d1f2579f656916666f662b71ed8879cea9ae045bd09e4a0f7234ffdd9287b
5
+ SHA512:
6
+ metadata.gz: b0b3b5e9c1df384a2326f47a9294695ea63b0fc9a4dca6f819c21c6aca179f8e982e889fc05be89e9b39a255e63cea8b954e9fc38d4e3e142447177053999278
7
+ data.tar.gz: 20f18380013d3e3a3f5fd18b615a77c39f7413b7bf61f6e46464f8e513cc07fb1843f9828573d390d187d4aee10c31976942cbd1542bb29a1636572b62ca10b9
data/lib/strock_bot.rb ADDED
@@ -0,0 +1,38 @@
1
+ # Sorawichaya Tiratrakoonwichaya
2
+ # 6210545602
3
+
4
+ require 'net/http'
5
+ require 'uri'
6
+ require 'Nokogiri'
7
+ require 'open-uri'
8
+
9
+ class Strock
10
+ def bot
11
+ str = ""
12
+ alphabets = "A".."Z"
13
+ alphabets.to_a.each do |i|
14
+ url = "https://www.set.or.th/set/commonslookup.do?language=th&country=TH&prefix=#{i}"
15
+ source = Net::HTTP.get(URI.parse(url))
16
+ document = Nokogiri::HTML.parse(source)
17
+ td_arr = document.css("td")
18
+ (0..td_arr.length-1).each do |j|
19
+ if (j+1)%3 == 0
20
+ link = "https://www.set.or.th/set/companyhighlight.do?symbol=#{td_arr[j-2].text}"
21
+ src = Net::HTTP.get(URI.parse(link))
22
+ doc = Nokogiri::HTML.parse(src)
23
+ td = doc.css("td").to_a
24
+ (3..td.length-1).each do |i|
25
+ if td[i].text == "หนี้สินรวม"
26
+ str += td[i-2].text
27
+ break;
28
+ end
29
+ end
30
+ str += "\n"
31
+ else
32
+ str += td_arr[j].text + " : "
33
+ end
34
+ end
35
+ end
36
+ puts str
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: strock_bot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sorawichaya Tiratrakoonwichaya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A strock bot
14
+ email: tsorawichaya@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/strock_bot.rb
20
+ homepage: https://rubygems.org/gems/strock_bot
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: Strock Bot!
43
+ test_files: []