Amazon_Best_Sellers 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b2b7677122d842a5209599da1d0f6692dd821d01
4
+ data.tar.gz: dbd4bb85f24f2b94e6fc2684149204d57633514e
5
+ SHA512:
6
+ metadata.gz: 3bc8eae074bc4a0e9e0c278bb555df8e9bb798744e476a73e48dc6f92232a6937178addac776c520a3a6a741e46a636dae8f93c7c3e4aa8e407e6afc82bfb358
7
+ data.tar.gz: 122635b83ce740608a45c9a91005e2740ccd1c5c79fb1fc8c0374d7677e1857bcf58f28c5aeea7d4fe2942c766cf7a4c510cb0a5f5e2c470abd0681d7f1b7c1e
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'Amazon_Best_Sellers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "Amazon_Best_Sellers"
8
+ spec.version = AmazonBestSellers::VERSION
9
+ spec.authors = ["Tsundu"]
10
+ spec.email = ["osmentdan@gmail.com"]
11
+
12
+ spec.summary = %q{Scrapes the Amazon Best Sellers page for the department names and the top three products in each department
13
+ with their links.}
14
+ #spec.description = %q{TODO: Write a longer description or delete this line.}
15
+ spec.homepage = "https://github.com/Tsundu/Amazon_best_sellers"
16
+ spec.license = "MIT"
17
+
18
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
19
+ # delete this section to allow pushing this gem to any host.
20
+ #if spec.respond_to?(:metadata)
21
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
22
+ #else
23
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
24
+ #end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.11"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_dependency "nokogiri"
35
+
36
+ spec.add_dependency "pry"
37
+ end
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at osmentdan@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ # Specify your gem's dependencies in Amazon_Best_Sellers.gemspec
5
+ gemspec
6
+
7
+ #```ruby
8
+ #gem 'Amazon_Best_Sellers'
9
+ #```
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Tsundu
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.
@@ -0,0 +1,34 @@
1
+ # AmazonBestSellers
2
+
3
+ #Scrapes Amazon.com's best sellers page to gather the departments and items in each.
4
+
5
+ ## Installation
6
+
7
+
8
+ And then execute:
9
+
10
+ $ bundle
11
+
12
+ Or install it yourself as:
13
+
14
+ $ gem install Amazon_Best_Sellers
15
+
16
+ ## Usage
17
+
18
+
19
+
20
+ ## Development
21
+
22
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
23
+
24
+ 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).
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/Amazon_Best_Sellers. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
29
+
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
34
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "Amazon_Best_Sellers"
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
+
11
+
12
+ require "irb"
13
+ IRB.start
14
+
15
+
16
+
17
+
18
+
19
+ require "pry"
20
+ Pry.start
@@ -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,20 @@
1
+ require "Amazon_Best_Sellers/version"
2
+ require "scraper.rb"
3
+ require "controller.rb"
4
+ require "department.rb"
5
+ require 'pry'
6
+
7
+
8
+
9
+
10
+
11
+ Controller.welcome
12
+ Controller.list
13
+ Controller.input
14
+
15
+
16
+
17
+
18
+
19
+
20
+
@@ -0,0 +1,3 @@
1
+ module AmazonBestSellers
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,102 @@
1
+ require_relative "../lib/scraper.rb"
2
+ require_relative "../lib/department.rb"
3
+
4
+ require 'pry'
5
+
6
+ class Controller
7
+ #attr_accessor :item, :company, :stars, :reviews, :dep, :link
8
+
9
+ def self.welcome
10
+ puts "Welcome to the Amazon Best Seller Listing Gem.\nThe following are the departments by which you may choose from."
11
+ end
12
+
13
+
14
+ def self.list ## Lists all of the department names from the ruby best sellers list.
15
+
16
+ Scraper.dep.each.with_index(1){|dep, index| puts "#{index}. #{dep}"}
17
+
18
+ end
19
+
20
+
21
+
22
+ def self.input ## grabs input from the user about which department they want to see the top items and displays it.
23
+
24
+ dep = Scraper.dep
25
+ item = Scraper.item_name
26
+ company = Scraper.item_company
27
+ link = Scraper.product_link
28
+
29
+ puts "Type in one of the department numbers to see the details"
30
+ input = ""
31
+
32
+ until input == "exit"
33
+
34
+ input = gets.strip
35
+
36
+
37
+
38
+ if input == "1"
39
+ puts "Top 3 items in the #{dep[0]} department."
40
+ puts " "
41
+ puts "1. #{item[0]} #{company[0]} || link : #{link[0]}"
42
+ puts " "
43
+ puts "2. #{item[1]} #{company[1]} || link : #{link[1]}"
44
+ puts " "
45
+ puts "3. #{item[2]} #{company[2]} || link : #{link[2]}"
46
+ puts " "
47
+ elsif input =="2"
48
+ puts "Top 3 items in the #{dep[1]} department."
49
+ puts " "
50
+ puts "1. #{item[3]} #{company[3]} || link : #{link[3]}"
51
+ puts " "
52
+ puts "2. #{item[4]} #{company[4]} || link : #{link[4]}"
53
+ puts " "
54
+ puts "3. #{item[5]} #{company[5]} || link : #{link[5]}"
55
+ puts " "
56
+ elsif input == "3"
57
+ puts "Top 3 items in the #{dep[2]} department."
58
+ puts " "
59
+ puts "1. #{item[6]} #{company[6]} || link : #{link[6]}"
60
+ puts " "
61
+ puts "2. #{item[7]} #{company[7]} || link : #{link[7]}"
62
+ puts " "
63
+ puts "3. #{item[8]} #{company[8]} || link : #{link[8]}"
64
+ puts " "
65
+ elsif input == "4"
66
+ puts "Top 3 items in the #{dep[3]} department."
67
+ puts " "
68
+ puts "1. #{item[9]} #{company[9]} || link : #{link[9]}"
69
+ puts " "
70
+ puts "2. #{item[10]} #{company[10]} || link : #{link[10]}"
71
+ puts " "
72
+ puts "3. #{item[11]} #{company[11]} || link : #{link[11]}"
73
+ puts " "
74
+ elsif input == "5"
75
+ puts "Top 3 items in the #{dep[4]} department."
76
+ puts " "
77
+ puts "1. #{item[12]} #{company[12]} || link : #{link[12]}"
78
+ puts " "
79
+ puts "2. #{item[13]} #{company[13]} || link : #{link[13]}"
80
+ puts " "
81
+ puts "3. #{item[14]} #{company[14]} || link : #{link[14]}"
82
+ puts " "
83
+ elsif input == "6"
84
+ puts "Top 3 items in the #{dep[5]} department."
85
+ puts " "
86
+ puts "1. #{item[15]} #{company[15]} || link : #{link[15]}"
87
+ puts " "
88
+ puts "2. #{item[16]} #{company[16]} || link : #{link[16]}"
89
+ puts " "
90
+ puts "3. #{item[17]} #{company[17]} || link : #{link[17]}"
91
+ puts " "
92
+ elsif input == 'list'
93
+ Controller.list
94
+ end
95
+
96
+ puts "Choose a different department, type list to list the departments again, or type exit to exit."
97
+
98
+ end
99
+
100
+ end
101
+
102
+ end
@@ -0,0 +1,21 @@
1
+ require_relative "../lib/scraper.rb"
2
+ require_relative "../lib/controller.rb"
3
+
4
+
5
+
6
+
7
+
8
+ class Department ### Goal is to create a department object for each department on the best sellers and to have each department store the
9
+ ## top three items.
10
+ attr_accessor :name
11
+
12
+ @@all = []
13
+
14
+ def initialize(name)
15
+ @name = name
16
+ #@items = []
17
+ @@all << self
18
+ end
19
+
20
+
21
+ end
@@ -0,0 +1,53 @@
1
+ require_relative "../lib/department.rb"
2
+ require_relative "../lib/controller.rb"
3
+
4
+
5
+
6
+ require 'open-uri'
7
+ require 'nokogiri'
8
+ require 'pry'
9
+
10
+ class Scraper
11
+
12
+ attr_accessor :departments, :cat, :page
13
+
14
+ @page = Nokogiri::HTML(open("http://www.amazon.com/Best-Sellers/zgbs"))
15
+
16
+
17
+ def self.dep
18
+ @page.css('.zg_homeWidget > h3').collect{|x| x.text}
19
+ end
20
+
21
+
22
+ def self.item_name
23
+ @page.css(".zg_title").collect{|x| x.text.strip}
24
+ end
25
+
26
+
27
+ def self.product_link
28
+ h = []
29
+ i = 1
30
+
31
+ Scraper.item_name.count.times do |i|
32
+
33
+ h << "www.amazon.com" + @page.css(".zg_title a")[i]["href"]
34
+ end
35
+ h
36
+ end
37
+
38
+
39
+
40
+ def self.item_company
41
+ h = []
42
+ i = 1
43
+
44
+ Scraper.item_name.count.times do |i|
45
+
46
+ h << @page.css(".zg_itemInfo")[i].css("span")[1].text.strip
47
+ end
48
+ h
49
+
50
+ end
51
+
52
+
53
+ end
@@ -0,0 +1,24 @@
1
+ To do listed by priorities
2
+
3
+ 1. Fix stars and number of reviews
4
+ 2. record walkthrough
5
+
6
+
7
+ def self.stars ## For getting the stars of products
8
+ @page.css(".a-icon-alt").collect{|x| x.text.strip} ### Fix for if no reviews
9
+ end
10
+
11
+
12
+ def self.rev_num ## For getting the number of reviewers
13
+ @page.css(".a-size-small a").collect{|x| x.text} ### Fix for if no reviews
14
+ end
15
+
16
+ #{stars[2]} stars by #{reviews[2]} people.
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Amazon_Best_Sellers
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tsundu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-01-24 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
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: pry
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:
84
+ email:
85
+ - osmentdan@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Amazon_Best_Sellers.gemspec
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - lib/Amazon_Best_Sellers.rb
102
+ - lib/Amazon_Best_Sellers/version.rb
103
+ - lib/controller.rb
104
+ - lib/department.rb
105
+ - lib/scraper.rb
106
+ - notes.md
107
+ homepage: https://github.com/Tsundu/Amazon_best_sellers
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.4.5.1
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Scrapes the Amazon Best Sellers page for the department names and the top
131
+ three products in each department with their links.
132
+ test_files: []