set_results 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/set_results.rb +38 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fa1fce9a6ea6b68fae07bef0caa804e3f573f79b8952fe3d5ccf7e5ebf476292
|
4
|
+
data.tar.gz: 2f7fd82db594c2c23815f1fd40fd4b5fb8e206b89bb6205bcf1caf6455f96d62
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7366c5c90a80faf77bb9aed39f0108afb427d46048912a9525afe0ec0bc00d0453906201a3ccfe3e7afb4f9293d2bc33082652a5932358a09e77137ea695eda6
|
7
|
+
data.tar.gz: 7b10152513524621e7fe41008033922eeadda07c010de3707b233885d169108434cdca94dcddb7cad2e62d27b7ab6b8553ab940513a1f4eec685e271c2389195
|
data/lib/set_results.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Purich Trainorapong
|
2
|
+
# 6210545581
|
3
|
+
|
4
|
+
require 'open-uri'
|
5
|
+
require 'nokogiri'
|
6
|
+
|
7
|
+
class SetResult
|
8
|
+
def self.main
|
9
|
+
html = URI.open("https://www.set.or.th/set/commonslookup.do")
|
10
|
+
response = Nokogiri::HTML(html)
|
11
|
+
link = response.css('div.capital-letter a').map { |link| link['href'] }
|
12
|
+
link.each do |each_page|
|
13
|
+
html = URI.open("https://www.set.or.th#{each_page}")
|
14
|
+
response = Nokogiri::HTML(html)
|
15
|
+
links = response.css("td a").each do |each_link|
|
16
|
+
real_link = each_link.attributes["href"].value.gsub('companyprofile','companyhighlight')
|
17
|
+
each_html = URI.open("https://www.set.or.th#{real_link}")
|
18
|
+
each_response = Nokogiri::HTML(each_html)
|
19
|
+
name = each_response.css("h3").text
|
20
|
+
price = each_response.css("tr[2]").text
|
21
|
+
split_price = price.split
|
22
|
+
split_price.reverse.each do |i|
|
23
|
+
x = i.gsub(',','')
|
24
|
+
float_x = x.to_f
|
25
|
+
if float_x.kind_of? Float
|
26
|
+
if float_x != 0.0
|
27
|
+
price = i
|
28
|
+
break
|
29
|
+
else
|
30
|
+
price = 'Not found'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
puts"#{name} : #{price}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: set_results
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Purich Trainorapong 6210545581
|
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 value of the stock market on SET.
|
14
|
+
email: purich.t@ku.th
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/set_results.rb
|
20
|
+
homepage: https://rubygems.org/gems/set_results
|
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: Check all SET's value!
|
43
|
+
test_files: []
|