stock_gem 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.
- checksums.yaml +7 -0
- data/lib/stock_gem.rb +33 -0
- metadata +42 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8bc79add6a0145ecefa31294cfdf3e08c95e34a61713c955ad744a2817c3c8c5
|
4
|
+
data.tar.gz: 706859fb94adc18a565e8a8d5e8bec82cefd9088b95f506e57c2971924349788
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 28a29f1e36d7dc7d489afeb5748e51d6d8babc139b3b86d3755a97dc13dc52d3b544a74f6291577c65a879141086b51c749430221bd1d15155f7f6576ef366b5
|
7
|
+
data.tar.gz: 16a7bc8b298d645c0de35d296b3cb5d644114f683d9291f14babab9cd47c1a494616c82a968a555b76fe12bed65c6c03033c545217cdb1b10ba3926734580dd3
|
data/lib/stock_gem.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#Bhatara Chaemchan
|
2
|
+
#6210545998
|
3
|
+
require 'net/http'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'nokogiri'
|
6
|
+
|
7
|
+
prefix = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
8
|
+
prefix_list = prefix.split("")
|
9
|
+
prefix_list.each do |prefix|
|
10
|
+
pre_url = 'https://www.set.or.th/set/commonslookup.do?language=th&country=TH&prefix='+prefix
|
11
|
+
document = open(pre_url)
|
12
|
+
content = document.read
|
13
|
+
parsed_content = Nokogiri::HTML(content)
|
14
|
+
|
15
|
+
a = parsed_content.css('table.table-profile.table-hover.table-set-border-yellow').css('a')
|
16
|
+
a.each do |link|
|
17
|
+
sub_link = link['href']
|
18
|
+
link = 'https://www.set.or.th/' + sub_link
|
19
|
+
document = open(link)
|
20
|
+
content = document.read
|
21
|
+
parsed_content = Nokogiri::HTML(content)
|
22
|
+
com_name = parsed_content.xpath('//*[@id="maincontent"]/div/div[1]/div[1]/h3').text
|
23
|
+
|
24
|
+
sub_link.gsub!('companyprofile', 'companyhighlight')
|
25
|
+
link = 'https://www.set.or.th/' + sub_link
|
26
|
+
document = open(link)
|
27
|
+
content = document.read
|
28
|
+
parsed_content = Nokogiri::HTML(content)
|
29
|
+
money = parsed_content.xpath('//*[@id="maincontent"]/div/div[4]/table/tbody[1]/tr[2]/td[5]').text
|
30
|
+
|
31
|
+
puts result = com_name + ' : ' + money
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stock_gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bhatara Chaemchan SKE17
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/stock_gem.rb
|
20
|
+
homepage:
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubygems_version: 3.0.3
|
39
|
+
signing_key:
|
40
|
+
specification_version: 4
|
41
|
+
summary: stock_gem is the gem to capture Thai stock from SET
|
42
|
+
test_files: []
|