set_stock 1.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.
- checksums.yaml +7 -0
- data/lib/set_stock.rb +45 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 797c45ac0eae0e2226764cad7861f83749de2c94c8ede5fe1a3cae91c3eb0e5f
|
4
|
+
data.tar.gz: 502fb0ddca52ce1b9904df5d52460234adc7aee9066678d6864b9d6074fd5bc7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6c16b09067210ba8934b8905783c195a4058a331d0c4e45dddb57be9b5907c6e0700a10eb6dcf53158e41fc6597e048de9c3c3fa6206c007d3df1342cc29a504
|
7
|
+
data.tar.gz: b33cf38bcec96fb2feb75d0b48dd4916128b4bdc0ee7595d8259fab1096981c2d1799e0dd7fc722fe6eff4aed7d7bfc07c0e367ea40ede450b9b1f4f07dfbc60
|
data/lib/set_stock.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#Panida Ounnaitham
|
2
|
+
#6210545513
|
3
|
+
|
4
|
+
require 'open-uri'
|
5
|
+
require 'nokogiri'
|
6
|
+
|
7
|
+
class SetStock
|
8
|
+
def self.stocks
|
9
|
+
alpha = *('A'..'Z').each do|i|
|
10
|
+
puts alpha
|
11
|
+
html = URI.open("https://www.set.or.th/set/commonslookup.do?language=th&country=TH&prefix="+i)
|
12
|
+
response = Nokogiri::HTML(html)
|
13
|
+
link = response.css("td a").each do |newlink|
|
14
|
+
temp = newlink.attributes["href"].value
|
15
|
+
temp = temp.gsub('profile','highlight')
|
16
|
+
temp2="https://www.set.or.th"+temp
|
17
|
+
for_link=URI.open(temp2)
|
18
|
+
for_response = Nokogiri::HTML(for_link)
|
19
|
+
company = for_response.css("h3").text
|
20
|
+
|
21
|
+
assert = for_response.css("td[6]").first
|
22
|
+
if assert == nil or assert.text.gsub("\u00A0", '') == ""
|
23
|
+
assert = for_response.css("td[5]").first
|
24
|
+
if assert == nil or assert.text.gsub("\u00A0", '') == ""
|
25
|
+
assert = for_response.css("td[4]").first
|
26
|
+
if assert == nil or assert.text.gsub("\u00A0", '') == ""
|
27
|
+
assert = for_response.css("td[3]").first
|
28
|
+
if assert == nil or assert.text.gsub("\u00A0", '') == ""
|
29
|
+
assert = for_response.css("td[2]").first
|
30
|
+
if assert == nil or assert.text.gsub("\u00A0", '') == ""
|
31
|
+
assert = "not found"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
puts company+" : "+assert
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: set_stock
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Panida Ounnaitham 6210545513
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A web scraper that show the stock name on and print the last assets value
|
14
|
+
email: panida.ou@ku.th
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/set_stock.rb
|
20
|
+
homepage: https://rubygems.org/gems/set_stock
|
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.0.3
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Show the last assets value of each company
|
43
|
+
test_files: []
|