SET_Theetouch 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '04787600eea7f64fc257c58bea21237a31344b2261243066a5a2fea75633ce2e'
4
+ data.tar.gz: e17a048f51178ce30a746e7d44d598388da2fcdec2cc13b1da908e13c99b706d
5
+ SHA512:
6
+ metadata.gz: 1705790eaa8ca06d315c3bbfbff26b3dea1658aef10def0b0272937e0e38647aeae09d24247fa43bef4dbe144a4e88efe1a4cdd44b1323f4d8d3ac74dcd5327a
7
+ data.tar.gz: efbe2cc6acad9816202e655ab6ebba8710b2e3fe4834a8786519f3ce73ef91ebac328b45f202f18a22cf1e1b6f8f89fadde8311823430d60ea13e938ebb0508c
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in SET_Theetouch.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Theetouch Kasemarnontana
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # SETTheetouch
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/SET_Theetouch`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Requirements
8
+
9
+ - ruby >=2.5
10
+ - JRuby >= 9.2.0.0
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'SET_Theetouch'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install SET_Theetouch
27
+
28
+ ## Usage
29
+
30
+ Simple ruby script to read and extract current assets of stock from [SET](https://www.set.or.th/set/commonslookup.do)
31
+ This script is a part of KU Softspec 2020.
32
+ Created by Theetouch KASEMARNONTANA 6210545483.
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lisbono2001/SET_Theetouch.
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "SET_Theetouch/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "SET_Theetouch"
8
+ spec.version = SETTheetouch::VERSION
9
+ spec.authors = ["Theetouch Kasemarnontana"]
10
+ spec.email = ["58279552+lisbono2001@users.noreply.github.com"]
11
+
12
+ spec.summary = %q{SET web scraper}
13
+ spec.description = %q{Simple ruby script to read and extract current assets of stock from SET}
14
+ spec.homepage = "https://github.com/lisbono2001/SET_webscraper"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.17"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_dependency "httparty" "~>0.18.1"
27
+ spec.add_dependency "nokogiri" "~>1.10.1"
28
+ spec.add_dependency "byebug" "~>11.1.3"
29
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "SET_Theetouch"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ require "SET_Theetouch/version"
2
+
3
+ module SETTheetouch
4
+ def scraper
5
+ url = "https://www.set.or.th/set/commonslookup.do"
6
+ parsed_page = Nokogiri::HTML(HTTParty.get(url).body)
7
+
8
+ # loop through all page
9
+ subpage_list ||= parsed_page.css('div.capital-letter').css('a')
10
+ subpage_list.each do |subpage_listing|
11
+ subpage_url ||= "https://www.set.or.th" + subpage_listing.attributes["href"].value
12
+ subpage = Nokogiri::HTML(HTTParty.get(subpage_url).body)
13
+ # loop through each company
14
+ company_list = subpage.css('tr')[1..-1]
15
+ company_list.each do |company_listing|
16
+ print company_listing.css('td')[0].text + " : "
17
+ print company_listing.css('td')[1].text + " : "
18
+
19
+ # print each company asset
20
+ company_url ||= "https://www.set.or.th" + company_listing.css('a')[0].attributes["href"].value
21
+ company_page = Nokogiri::HTML(HTTParty.get(company_url).body)
22
+ company_asset_url ||= "https://www.set.or.th" + company_page.css('ul.set-nav-tabs').css('a')[1].attributes["href"].value
23
+
24
+ company_asset_page = Nokogiri::HTML(HTTParty.get(company_asset_url).body)
25
+ asset_info = company_asset_page.css('table.table-info').css('tr')[2].css('td') # select row
26
+ puts asset_info[asset_info.length()-2].text
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ class Output
33
+ include SETTheetouch
34
+ end
@@ -0,0 +1,3 @@
1
+ module SETTheetouch
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: SET_Theetouch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Theetouch Kasemarnontana
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: httparty~>0.18.1
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri~>1.10.1
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug~>11.1.3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Simple ruby script to read and extract current assets of stock from SET
84
+ email:
85
+ - 58279552+lisbono2001@users.noreply.github.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - SET_Theetouch.gemspec
96
+ - bin/console
97
+ - bin/setup
98
+ - lib/SET_Theetouch.rb
99
+ - lib/SET_Theetouch/version.rb
100
+ homepage: https://github.com/lisbono2001/SET_webscraper
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubygems_version: 3.0.3
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: SET web scraper
123
+ test_files: []