stock6005 0.0.1 → 1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/stock6005.rb +28 -24
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19cd78fcd5ea1c2b4b134215dc8f77cafa8c810b86d66c723752bbaff206a5b7
4
- data.tar.gz: b2e5533b4f12bb554490ec180aa96bf21ebaf08c9927329451c225e941fd8be2
3
+ metadata.gz: 95631cb3544093364efc0559984edf201ca85de1d157099a88c2101ff9c1e63f
4
+ data.tar.gz: f22457b7e7030754d5f9bc9da9e1051ae2b4b670a374b7cea9f3b832d35ff30e
5
5
  SHA512:
6
- metadata.gz: a945b775359c7ac84d445f0e883371f11d1be479497c727921b25834edcd56162e1925d6ef1021166b8dcba9e920327477754d5ac9529d390fd89b3936dd5559
7
- data.tar.gz: '039b1ff925923bc5fcffbf450ef2a258c4a2f7cb24467470c8a5ce19290086a94639837d5d1693e70b95ea0181a7d79b4b26066792da9b1d269172bec60c686b'
6
+ metadata.gz: d18769c5b685c6c275dfb19905adfb0970510a9e3c71406a28124d450e340a7605e2cd05ef15198c612495406d548a1376900d80b7f4a21629512f9101b987f7
7
+ data.tar.gz: 8f62b270853151eaea3d17d8351c8dc0af316657c6d17e57005e2c65189f36c7c04fed40d93c905f8b55adff28cd10f4caf68400e3c4e51eb2a9a2b96353867c
data/stock6005.rb CHANGED
@@ -4,34 +4,38 @@
4
4
  require 'nokogiri'
5
5
  require 'httparty'
6
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
7
+ def print_stock
8
+ url = 'https://www.set.or.th/set/commonslookup.do'
9
+ unparsed_page = HTTParty.get(url)
10
+ parsed_page = Nokogiri::HTML(unparsed_page.body)
11
+
12
+ pagination_urls = []
13
+ pagination_lists = parsed_page.css('div.col-xs-12.padding-top-10.text-center.capital-letter').children.css('a')
14
+ pagination_lists.each do |page_list|
15
+ pagination_urls << "https://www.set.or.th#{page_list.attributes['href'].value}"
16
+ end
16
17
 
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')
18
+ pagination_urls.each do |pagination_url|
19
+ pagination_unparsed_page = HTTParty.get(pagination_url)
20
+ pagination_parsed_page = Nokogiri::HTML(pagination_unparsed_page.body)
21
+ set_lists = pagination_parsed_page.css('tr')
21
22
 
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)
23
+ set_lists.drop(1).each do |set_list|
24
+ set_url = "https://www.set.or.th#{set_list.children.children[0]['href']}"
25
+ set_unparsed_page = HTTParty.get(set_url)
26
+ set_parsed_page = Nokogiri::HTML(set_unparsed_page.body)
26
27
 
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)
28
+ set_table_url = "https://www.set.or.th#{set_parsed_page.css('ul.nav.nav-tabs.set-nav-tabs').children.css('a')[1]
29
+ .attributes['href'].value}"
30
+ set_table_unparsed_page = HTTParty.get(set_table_url)
31
+ set_table_parsed_page = Nokogiri::HTML(set_table_unparsed_page.body)
31
32
 
32
- name = set_table_parsed_page.css('h3').text
33
- total = set_table_parsed_page.css('tbody').css('tr')[1].css('td')[-2].text
33
+ name = set_table_parsed_page.css('h3').text
34
+ total = set_table_parsed_page.css('tbody').css('tr')[1].css('td')[-2].text
34
35
 
35
- puts "#{name} : #{total}"
36
+ puts "#{name} : #{total}"
37
+ end
36
38
  end
37
39
  end
40
+
41
+ print_stock
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stock6005
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bheem Suttipong