set_scraping 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd51823d6c96b5f85d742af9ef7cdc966fa1b91b4d9e1d2af376b029d517eb5b
4
- data.tar.gz: 6543cdb88373d319354ffbdaf0dfa10f552bd2d23c3e453fdafe6ca8cd46ac8a
3
+ metadata.gz: 804d13c5fe874597cbba2f99c8b1a3d4f8114890fdd0f69c8ef6624026673abc
4
+ data.tar.gz: cee580d70f9b38ba1d160979263753069a3c1b3dabe2eb07b187d00368180581
5
5
  SHA512:
6
- metadata.gz: 1a89ec8dd850d8694ab07331068082b48a2098bbb83db9a56e261a62ba9ad0162c9e65ebf8fd1fbe38a15dd3464a0f892dbd5885a5da545f422947c5760b0c8c
7
- data.tar.gz: 882e278abd75a5933ee62ff4fff61f1ec19cf4eba86b304180144c90ffce7a3742bbcfcf83c0321588c03533054ce3ef297e0c2e97ebf24fb3c5341bac7e486d
6
+ metadata.gz: 452bc8074d403256242e1f98fa9d2e25043bdb2120062744b73aa9aa9e61e18418482a644194ce8b6d7212c5a987aad352fccbf749227f019f333243b7a92f34
7
+ data.tar.gz: 788bb747877b03f82f4a0a918fd6bfc076cf71a07f93f64b2eb510fa7f81398f7e0cd4610f6dc67551c6609631fb35617d2b37b30a109e890fe78e3533ca0222
@@ -0,0 +1,39 @@
1
+ # Chananya Photan
2
+ # 6110545481
3
+
4
+ require 'Nokogiri'
5
+ require 'open-uri'
6
+
7
+ class SetScraping
8
+
9
+ def scraping
10
+ main = 'https://www.set.or.th/'
11
+ all_company = 'https://www.set.or.th/set/commonslookup.do?language=th&country=TH&prefix='
12
+ all_alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
13
+
14
+ all_alphabet.each_char { |each_alphabet|
15
+ each_url_prefix = open(all_company + each_alphabet)
16
+ all_company_prefix = Nokogiri::HTML(each_url_prefix)
17
+ # Get all info url of company from each alphabet
18
+ all_company_info = all_company_prefix.xpath('//*[@id="maincontent"]/div/div/div[3]/table').css('a').map { |l| l['href'] }
19
+
20
+ all_company_info.each do |each_company_info|
21
+ company_info = open(main + each_company_info)
22
+ new_source = Nokogiri::HTML(company_info)
23
+ # Get Profit url of each company
24
+ all_profits_path = new_source.xpath('//*[@id="maincontent"]/div/div[2]/div/ul/li[2]/a').map { |l| l['href'] }
25
+
26
+ all_profits_path.each do |each_profits_path|
27
+ # Open profit path of each company
28
+ each_company_profits = open(main + each_profits_path)
29
+ profits_source = Nokogiri::HTML(each_company_profits)
30
+ # Get company's name
31
+ company_name = profits_source.xpath('//*[@id="maincontent"]/div/div[1]/div[1]/h3').text
32
+ # Get company's asset
33
+ company_asset = profits_source.xpath('//*[@id="maincontent"]/div/div[4]/table/tbody[1]/tr[2]/td[5]').text
34
+ puts '%s : ' % company_name + company_asset
35
+ end
36
+ end
37
+ }
38
+ end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: set_scraping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chananya Photan 6110545481
@@ -16,7 +16,7 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - set_scraping/lib/set_scraping.rb
19
+ - lib/set_scraping.rb
20
20
  homepage: https://rubygems.org/gems/set_scraping
21
21
  licenses:
22
22
  - MIT
@@ -1,36 +0,0 @@
1
- # Chananya Photan
2
- # 6110545481
3
-
4
- require 'Nokogiri'
5
- require 'open-uri'
6
-
7
- main = 'https://www.set.or.th/'
8
- all_company = 'https://www.set.or.th/set/commonslookup.do?language=th&country=TH&prefix='
9
- all_alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
10
-
11
- all_alphabet.each_char { |each_alphabet|
12
- each_url_prefix = open(all_company + each_alphabet)
13
- all_company_prefix = Nokogiri::HTML(each_url_prefix)
14
- # Get all info url of company from each alphabet
15
- all_company_info = all_company_prefix.xpath('//*[@id="maincontent"]/div/div/div[3]/table').css('a').map { |l| l['href'] }
16
-
17
- all_company_info.each do |each_company_info|
18
- company_info = open(main + each_company_info)
19
- new_source = Nokogiri::HTML(company_info)
20
- # Get Profit url of each company
21
- all_profits_path = new_source.xpath('//*[@id="maincontent"]/div/div[2]/div/ul/li[2]/a').map { |l| l['href'] }
22
-
23
- all_profits_path.each do |each_profits_path|
24
- # Open profit path of each company
25
- each_company_profits = open(main + each_profits_path)
26
- profits_source = Nokogiri::HTML(each_company_profits)
27
- # Get company's name
28
- company_name = profits_source.xpath('//*[@id="maincontent"]/div/div[1]/div[1]/h3').text
29
- # Get company's asset
30
- company_asset = profits_source.xpath('//*[@id="maincontent"]/div/div[4]/table/tbody[1]/tr[2]/td[5]').text
31
- puts '%s : ' % company_name + company_asset
32
- end
33
- end
34
- }
35
-
36
-