web_scraping_hw3 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 43df70e8b35697aef667f0b7651b530ab1018fbe1f864dc912ff8b178424f9d4
4
+ data.tar.gz: 319505b749cd831941cbd34092d4f36f198c91e6bc1c967eead11f78058b43e8
5
+ SHA512:
6
+ metadata.gz: de00322a33a340b8eca2f0c5920ada94175b6d19532f2711f78e793eaf135690e47cc05d7a7ce66678ca6780f884f7e2afefea920a8a6cde140062af3c6330d2
7
+ data.tar.gz: b5eddcc50ae0a84f1acf99b62b9f4508f0d3f855167c0386ea7b35d80d8e5d734e70b68646ef26d5635374d44450711cfed4cdd856446b57911729094d61471c
@@ -0,0 +1,13 @@
1
+ version: 2.1
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: ruby:2.6.6
6
+ steps:
7
+ - checkout
8
+ - run:
9
+ name: Run the default task
10
+ command: |
11
+ gem install bundler -v 2.2.6
12
+ bundle install
13
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,59 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ /Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
57
+
58
+ .idea
59
+
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.1.0] - 2017-06-20
8
+ ### Added
9
+
10
+ - Add the scraping for all list of corporation
11
+ - Scrape only the Asset of each corporations
@@ -0,0 +1,102 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for
6
+ everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity
7
+ and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion,
8
+ or sexual identity and orientation.
9
+
10
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to a positive environment for our community include:
15
+
16
+ * Demonstrating empathy and kindness toward other people
17
+ * Being respectful of differing opinions, viewpoints, and experiences
18
+ * Giving and gracefully accepting constructive feedback
19
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
20
+ * Focusing on what is best not just for us as individuals, but for the overall community
21
+
22
+ Examples of unacceptable behavior include:
23
+
24
+ * The use of sexualized language or imagery, and sexual attention or advances of any kind
25
+ * Trolling, insulting or derogatory comments, and personal or political attacks
26
+ * Public or private harassment
27
+ * Publishing others' private information, such as a physical or email address, without their explicit permission
28
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take
33
+ appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive,
34
+ or harmful.
35
+
36
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
37
+ issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for
38
+ moderation decisions when appropriate.
39
+
40
+ ## Scope
41
+
42
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing
43
+ the community in public spaces. Examples of representing our community include using an official e-mail address, posting
44
+ via an official social media account, or acting as an appointed representative at an online or offline event.
45
+
46
+ ## Enforcement
47
+
48
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible
49
+ for enforcement at james31366@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
50
+
51
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
52
+
53
+ ## Enforcement Guidelines
54
+
55
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem
56
+ in violation of this Code of Conduct:
57
+
58
+ ### 1. Correction
59
+
60
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the
61
+ community.
62
+
63
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation
64
+ and an explanation of why the behavior was inappropriate. A public apology may be requested.
65
+
66
+ ### 2. Warning
67
+
68
+ **Community Impact**: A violation through a single incident or series of actions.
69
+
70
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including
71
+ unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding
72
+ interactions in community spaces as well as external channels like social media. Violating these terms may lead to a
73
+ temporary or permanent ban.
74
+
75
+ ### 3. Temporary Ban
76
+
77
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
78
+
79
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified
80
+ period of time. No public or private interaction with the people involved, including unsolicited interaction with those
81
+ enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
82
+
83
+ ### 4. Permanent Ban
84
+
85
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate
86
+ behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
87
+
88
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
89
+
90
+ ## Attribution
91
+
92
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available
93
+ at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
94
+
95
+ Community Impact Guidelines were inspired
96
+ by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
97
+
98
+ [homepage]: https://www.contributor-covenant.org
99
+
100
+ For answers to common questions about this code of conduct, see the FAQ at
101
+ https://www.contributor-covenant.org/faq. Translations are available
102
+ at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in web_scraping_hw3.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.7"
13
+
14
+ gem "httparty", "~> 0.18.1"
15
+
16
+ gem "nokogiri", "~> 1.11.1"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Vichisorn
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,48 @@
1
+ # WebScrapingHw3
2
+
3
+ This gem is for web scraping inside the set website.
4
+ This gem is for the Soft Spec Design lab homework 3.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'web_scraping_hw3'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle install
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install web_scraping_hw3
21
+
22
+ ## Usage
23
+
24
+ No usage of this gem for now.
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
29
+ also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
32
+ version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
33
+ push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/james31366/Web-Scraping-HW3-SSD. This project
38
+ is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
39
+ the [code of conduct](https://github.com/james31366/Web-Scraping-HW3-SSD/blob/master/CODE_OF_CONDUCT.md).
40
+
41
+ ## License
42
+
43
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
44
+
45
+ ## Code of Conduct
46
+
47
+ Everyone interacting in the WebScrapingHw3 project's codebase, issue trackers, chat rooms and mailing lists is expected
48
+ to follow the [code of conduct](https://github.com/james31366/Web-Scraping-HW3-SSD/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "web_scraping_hw3"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ 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,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Vichisorn Wejsupakul
4
+ # 6210546013
5
+ require "nokogiri"
6
+ require "httparty"
7
+
8
+ require_relative "web_scraping_hw3/version"
9
+
10
+ # Use to Scraping the website of set to find the asset of all corporation.
11
+ module WebScrapingHw3
12
+ class Error < StandardError; end
13
+
14
+ BASE_URL = "https://www.set.or.th"
15
+
16
+ # Convert any url link from string to nokogiri html.
17
+ # To use with any nokogiri tools.
18
+ # @param [String] url
19
+ # @return [HTML]
20
+ def make_parsed(url)
21
+ unparsed_page = HTTParty.get(url)
22
+ Nokogiri::HTML(unparsed_page.body)
23
+ end
24
+
25
+ url = "#{BASE_URL}/set/commonslookup.do"
26
+ parsed_page = make_parsed(url)
27
+ companies_pages = parsed_page.css("div.col-xs-12.padding-top-10.text-center.capital-letter").css("a")
28
+
29
+ companies_pages.each do |companies_page|
30
+ companies_url = "#{BASE_URL}#{companies_page.attributes["href"].value}"
31
+ companies_parsed_page = make_parsed(companies_url)
32
+ companies_table = companies_parsed_page.css("table.table-profile.table-hover.table-set-border-yellow").css("a")
33
+
34
+ companies_table.each do |company_tag_a|
35
+ url_stock_profile_page = "#{BASE_URL}#{company_tag_a.attributes["href"].value}"
36
+ stock_profile_page = make_parsed(url_stock_profile_page)
37
+ url_stock_highlight_page = stock_profile_page.css("ul.nav.nav-tabs.set-nav-tabs")
38
+ .css("a")[1].attributes["href"].value
39
+
40
+ stock_url = "#{BASE_URL}#{url_stock_highlight_page}"
41
+ stock_parsed_page = make_parsed(stock_url)
42
+
43
+ name = stock_parsed_page.css("div.col-xs-12.col-md-12.col-lg-8").css("h3").text
44
+ stock_table_row = stock_parsed_page.css("table.table.table-hover.table-info").css("tr")
45
+ table_column = stock_table_row[2].css("td")
46
+ cost = table_column[-2].text
47
+
48
+ puts("#{name} : #{cost}")
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WebScrapingHw3
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/web_scraping_hw3/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "web_scraping_hw3"
7
+ spec.version = WebScrapingHw3::VERSION
8
+ spec.authors = ["Vichisorn"]
9
+ spec.email = ["james31366@gmail.com"]
10
+
11
+ spec.summary = "Web Scraping for Set website"
12
+ spec.description = "This gem is web scraping from assignment 2 in Soft spec design lab"
13
+ spec.homepage = "https://github.com/james31366/Web-Scraping-HW3-SSD"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/james31366/Web-Scraping-HW3-SSD"
19
+ spec.metadata["changelog_uri"] = "https://github.com/james31366/Web-Scraping-HW3-SSD/blob/master/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ # Dependency gem
31
+ spec.add_dependency "httparty", "~> 0.18.1"
32
+ spec.add_dependency "nokogiri", "~> 1.11.1"
33
+
34
+ # For more information and examples about making a new gem, checkout our
35
+ # guide at: https://bundler.io/guides/creating_gem.html
36
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: web_scraping_hw3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vichisorn
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.18.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.18.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.11.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.11.1
41
+ description: This gem is web scraping from assignment 2 in Soft spec design lab
42
+ email:
43
+ - james31366@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".circleci/config.yml"
49
+ - ".gitignore"
50
+ - ".rubocop.yml"
51
+ - CHANGELOG.md
52
+ - CODE_OF_CONDUCT.md
53
+ - Gemfile
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/console
58
+ - bin/setup
59
+ - lib/web_scraping_hw3.rb
60
+ - lib/web_scraping_hw3/version.rb
61
+ - web_scraping_hw3.gemspec
62
+ homepage: https://github.com/james31366/Web-Scraping-HW3-SSD
63
+ licenses:
64
+ - MIT
65
+ metadata:
66
+ homepage_uri: https://github.com/james31366/Web-Scraping-HW3-SSD
67
+ source_code_uri: https://github.com/james31366/Web-Scraping-HW3-SSD
68
+ changelog_uri: https://github.com/james31366/Web-Scraping-HW3-SSD/blob/master/CHANGELOG.md
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 2.4.0
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubygems_version: 3.2.6
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Web Scraping for Set website
88
+ test_files: []