stock6005 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/stock6005.rb +37 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2de88ddb237a612e8cc73456c2f0e432141a4a2d41324745f36c0cd237ce8d48
4
+ data.tar.gz: 998a5edee20d1937a5f2f77f58fe98a0480a61fcad4744cac01052ecd14243a2
5
+ SHA512:
6
+ metadata.gz: ad00a4cde5e630a41aee9a0f566d35d38fe78c0d56d7260f49a7df5b7bce8d878fa7f9e6a951f50e46065dfe3eed165d2d5740dde3c9dde04e970e206439a0ba
7
+ data.tar.gz: 99bed61d35d34ae679dbc3c93ba4404fe3612567fa96cd2bfd398208b3d07ad1cb00a506f70f84038c22da689ab0b2879466d75b21ca674023a4072001c852d9
data/stock6005.rb ADDED
@@ -0,0 +1,37 @@
1
+ # Bheem Suttipong
2
+ # 6210546005
3
+
4
+ require 'nokogiri'
5
+ require 'httparty'
6
+
7
+ url = 'https://www.set.or.th/set/commonslookup.do'
8
+ unparsed_page = HTTParty.get(url)
9
+ parsed_page = Nokogiri::HTML(unparsed_page.body)
10
+
11
+ pagination_urls = []
12
+ pagination_lists = parsed_page.css('div.col-xs-12.padding-top-10.text-center.capital-letter').children.css('a')
13
+ pagination_lists.each do |page_list|
14
+ pagination_urls << "https://www.set.or.th#{page_list.attributes['href'].value}"
15
+ end
16
+
17
+ pagination_urls.each do |pagination_url|
18
+ pagination_unparsed_page = HTTParty.get(pagination_url)
19
+ pagination_parsed_page = Nokogiri::HTML(pagination_unparsed_page.body)
20
+ set_lists = pagination_parsed_page.css('tr')
21
+
22
+ set_lists.drop(1).each do |set_list|
23
+ set_url = "https://www.set.or.th#{set_list.children.children[0]['href']}"
24
+ set_unparsed_page = HTTParty.get(set_url)
25
+ set_parsed_page = Nokogiri::HTML(set_unparsed_page.body)
26
+
27
+ set_table_url = "https://www.set.or.th#{set_parsed_page.css('ul.nav.nav-tabs.set-nav-tabs').children.css('a')[1]
28
+ .attributes['href'].value}"
29
+ set_table_unparsed_page = HTTParty.get(set_table_url)
30
+ set_table_parsed_page = Nokogiri::HTML(set_table_unparsed_page.body)
31
+
32
+ name = set_table_parsed_page.css('h3').text
33
+ total = set_table_parsed_page.css('tbody').css('tr')[1].css('td')[-2].text
34
+
35
+ puts "#{name} : #{total}"
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stock6005
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bheem Suttipong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-02-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: week2-assignment to gem
14
+ email: bheem.su@ku.th
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - stock6005.rb
20
+ homepage:
21
+ licenses:
22
+ - Bheem6005
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: week3-assignment
43
+ test_files: []