assignment3-5971 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/assignment3-5971.rb +33 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2a7a7c38f2c4bb3245fd81575fdf3eab4c0987011f4e44ba868a8bc1546459ce
4
+ data.tar.gz: 9869e5f1861b396dcc06a00193f2b4fe65b0ca2d2eace97a55cc9eb28386c744
5
+ SHA512:
6
+ metadata.gz: 334a31c79678572e5cc8fcc998264c1fbec42eadaf779f44e243574a8a3cd706cf4d74e6e78b90baa3f39fc2125959390302725230f8d6ab7498c5c5b5f03888
7
+ data.tar.gz: aa475f54eb3f22633ae1d595cd593b72e19ecdfd185293a3cdc123b9253c5f0e7478d3bc4cda4cac5f78575856cb151aaf6f984e59ff05aebd775a8c393a6ec5
@@ -0,0 +1,33 @@
1
+ # Narawish Sangsiriwut
2
+ # 6210545971
3
+ # frozen_string_literal: true
4
+
5
+ require 'nokogiri'
6
+ require 'httparty'
7
+
8
+ class Scraper
9
+ def self.scraper(url)
10
+ unparsed_page = HTTParty.get(url)
11
+ parse_content = Nokogiri::HTML(unparsed_page.body)
12
+ company = parse_content.css('h3').text
13
+ index = 4
14
+ asset = parse_content.css('tr')[2].css('td')
15
+ loop do
16
+ asset = parse_content.css('tr')[2].css('td')[index]
17
+ index -= 1
18
+ break if !asset.nil? || index == 1
19
+ end
20
+ puts "#{company}: #{asset.text}"
21
+ end
22
+
23
+ def self.main
24
+ lookup_url = 'https://www.set.or.th/set/commonslookup.do'
25
+ highlight_url = 'https://www.set.or.th/set/companyhighlight.do?symbol='
26
+ main_page = Nokogiri::HTML(HTTParty.get(lookup_url))
27
+ all_symbol = main_page.css('tr td a').map(&:text)
28
+ all_symbol.each do |symbol|
29
+ link = highlight_url + symbol
30
+ scraper(link)
31
+ end
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: assignment3-5971
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - NarawishS
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-02-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple stock price printing tool
14
+ email:
15
+ - narawish.s@ku.th
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - assignment3-5971.rb
21
+ homepage: https://rubygems.org/gems/6210545971_Assignment3
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.2.8
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Only usable for 'https://www.set.or.th/set/commonslookup.do'
44
+ test_files: []