steam-daily-deals 0.2.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/NOTES.md +21 -0
- data/README.md +27 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/steam-daily-deals +5 -0
- data/lib/steam_daily_deals.rb +13 -0
- data/lib/steam_daily_deals/cli.rb +188 -0
- data/lib/steam_daily_deals/deal.rb +42 -0
- data/lib/steam_daily_deals/scraper.rb +75 -0
- data/lib/steam_daily_deals/version.rb +3 -0
- data/spec.md +6 -0
- data/steam_daily_deals-0.1.0.gem +0 -0
- data/steam_daily_deals.gemspec +31 -0
- metadata +190 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d7fc1a3854455aa10194133b638870230c325a10
|
|
4
|
+
data.tar.gz: b5113004c3a105a9e58a0173c380064c350b88da
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: dd0fd8084b25f36f240cc6aeec72aadd126f2ff37d5dd26b09bb86d5d5c5973a31cbc7ecee80f16d7e1b1ead848f159450c74d7601da4daaa59573403a4deb00
|
|
7
|
+
data.tar.gz: 85710a2a9dce4f11f7a5fc54c9e6f99a9c0bedee7ce885ddc645b1ae194be01f2a62084fc6b2ccc152ef41068b057c46d69fcd5ce03d471e398a93791bbf4e4d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -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 bri.reynolds@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
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 arturusfury
|
|
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/NOTES.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Operation Methods
|
|
2
|
+
|
|
3
|
+
user types steam-daily-deals to start the program
|
|
4
|
+
steam-daily-deals calls the call method
|
|
5
|
+
|
|
6
|
+
call method displays our ASCII banner then calls the menu method
|
|
7
|
+
|
|
8
|
+
menu method waits for a user input
|
|
9
|
+
if the input is exit, closes the program
|
|
10
|
+
|
|
11
|
+
if the input is list, calls the list_deals method
|
|
12
|
+
|
|
13
|
+
if the input is a number that matches an index in our @deals array we display that game's information
|
|
14
|
+
|
|
15
|
+
list_deals method calls a scrape_main method
|
|
16
|
+
scrape_main uses nokogiri to pull the daily deal information css(main_cluster_scroll)
|
|
17
|
+
from there it will scrape the app page url, css(discount_final_price), and css(main_cap_status or css(game_description_snippet)
|
|
18
|
+
then calls the scrape_deal method
|
|
19
|
+
|
|
20
|
+
scrape_deal grabs the name css(apphub_AppName), css(release_date date), css(user_review_summary_row game_review_summary) and css(user_review_summary_row game_review_summary responsive_hidden)
|
|
21
|
+
scrape_deal will also grab the css(glance_tags popular_tags)
|
data/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Steam Daily Deals Gem
|
|
2
|
+
|
|
3
|
+
Using this ruby CLI gem you will be able to quickly see which games are on sale today. It will pull the information directly from the steam homepage so it should always be the most up to date information available to the public!
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
$ ruby bin/steam-daily-deals
|
|
8
|
+
|
|
9
|
+
## Development
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
The first time you run this program it might need to install PhantomJS if it isn't installed already. This will be automatic and should only happen once.
|
|
14
|
+
|
|
15
|
+
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).
|
|
16
|
+
|
|
17
|
+
## Contributing
|
|
18
|
+
|
|
19
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/arturusfury/steam_daily_deals. 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.
|
|
20
|
+
|
|
21
|
+
## Credits
|
|
22
|
+
|
|
23
|
+
I would like to thank the creators of Selenium-Webkit (https://github.com/SeleniumHQ/selenium/tree/master/rb), PhantomJS (https://github.com/ariya/phantomjs), the PhantomJS gem (https://github.com/colszowka/phantomjs-gem), and the Command Line Reporter (https://github.com/wbailey/command_line_reporter) tools for all their hard work which helped me complete my project.
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'steam_daily_deals'
|
|
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
|
data/bin/setup
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'pry'
|
|
2
|
+
require 'nokogiri'
|
|
3
|
+
require 'command_line_reporter'
|
|
4
|
+
require 'selenium-webdriver'
|
|
5
|
+
require 'phantomjs'
|
|
6
|
+
require 'open-uri'
|
|
7
|
+
|
|
8
|
+
require_relative './steam_daily_deals/version'
|
|
9
|
+
require_relative '../lib/steam_daily_deals/cli'
|
|
10
|
+
require_relative '../lib/steam_daily_deals/deal'
|
|
11
|
+
require_relative '../lib/steam_daily_deals/scraper'
|
|
12
|
+
|
|
13
|
+
Selenium::WebDriver::PhantomJS.path = Phantomjs.path
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Adding Colors to our strings
|
|
2
|
+
class String
|
|
3
|
+
def red; "\e[31m#{self}\e[0m" end
|
|
4
|
+
def green; "\e[32m#{self}\e[0m" end
|
|
5
|
+
def cyan; "\e[36m#{self}\e[0m" end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# CLI class
|
|
9
|
+
class SteamDailyDeals::CLI
|
|
10
|
+
def call
|
|
11
|
+
extend CommandLineReporter
|
|
12
|
+
|
|
13
|
+
# This part here looks pretty ugly with the heredoc, but I'm not sure of a
|
|
14
|
+
# better way to make sure I have all of this text centered and keep the look
|
|
15
|
+
# I was working toward. It can be completely removed and just made to have
|
|
16
|
+
# a regular "Welcome to the Steam Daily Deals" line, but this was an astetic
|
|
17
|
+
# choice
|
|
18
|
+
puts <<-DOC
|
|
19
|
+
|
|
20
|
+
ad88888ba 888888888888 88888888888 db 88b d88
|
|
21
|
+
d8" "8b 88 88 d88b 888b d888
|
|
22
|
+
Y8, 88 88 d8'`8b 88`8b d8'88
|
|
23
|
+
`Y8aaaaa, 88 88aaaaa d8' `8b 88 `8b d8' 88
|
|
24
|
+
`"""""8b, 88 88""""" d8YaaaaY8b 88 `8b d8' 88
|
|
25
|
+
`8b 88 88 d8""""""""8b 88 `8b d8' 88
|
|
26
|
+
Y8a a8P 88 88 d8' `8b 88 `888' 88
|
|
27
|
+
"Y88888P" 88 88888888888 d8' `8b 88 `8' 88
|
|
28
|
+
____ _ _ ____ _
|
|
29
|
+
| _ \\ __ _ (_)| | _ _ | _ \\ ___ __ _ | | ___
|
|
30
|
+
| | | | / _` || || || | | | | | | | / _ \\ / _` || |/ __|
|
|
31
|
+
| |_| || (_| || || || |_| | | |_| || __/| (_| || |\\__ \\
|
|
32
|
+
|____/ \\__,_||_||_| \\__, | |____/ \\___| \\__,_||_||___/
|
|
33
|
+
|___/
|
|
34
|
+
|
|
35
|
+
DOC
|
|
36
|
+
|
|
37
|
+
horizontal_rule(width: 160, color: 'red')
|
|
38
|
+
header(title: 'Please wait while we load todays daily deals', color: 'red', align: 'center', width: 160, spacing: 0)
|
|
39
|
+
make_deals
|
|
40
|
+
header(title: 'This may take a minute to load everything', color: 'red', align: 'center', width: 160, spacing: 0)
|
|
41
|
+
header(title: 'Progress:', color: 'red', align: 'center', width: 160, spacing: 0)
|
|
42
|
+
add_deal_details
|
|
43
|
+
horizontal_rule(width: 160, color: 'red')
|
|
44
|
+
vertical_spacing 1
|
|
45
|
+
menu
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def menu
|
|
49
|
+
print "Please type in list to get a list of today's deals on steam or type exit: ".cyan
|
|
50
|
+
input = nil
|
|
51
|
+
until input == 'exit'
|
|
52
|
+
input = gets.strip.downcase
|
|
53
|
+
|
|
54
|
+
if input.to_i.between?(1, SteamDailyDeals::Deal.all.count)
|
|
55
|
+
show_deal(input.to_i)
|
|
56
|
+
elsif input == 'list'
|
|
57
|
+
list_deals
|
|
58
|
+
elsif input == 'exit'
|
|
59
|
+
puts 'See you tomorrow!'.green
|
|
60
|
+
else
|
|
61
|
+
puts "I'm sorry that was not a valid entry".red
|
|
62
|
+
print "Please type list to get a list of today's deals or type exit to quit the program: ".cyan
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def make_deals
|
|
68
|
+
deals_array = SteamDailyDeals::Scraper.scrape_index_page.uniq
|
|
69
|
+
SteamDailyDeals::Deal.create_from_collection(deals_array)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def add_deal_details
|
|
73
|
+
line_count = 0
|
|
74
|
+
|
|
75
|
+
SteamDailyDeals::Deal.all.each do |deal|
|
|
76
|
+
info = SteamDailyDeals::Scraper.scrape_deal_page(deal.app_url)
|
|
77
|
+
deal.add_deal_information(info)
|
|
78
|
+
print '='.red * (160 / SteamDailyDeals::Deal.all.uniq.count)
|
|
79
|
+
line_count += (160 / SteamDailyDeals::Deal.all.uniq.count)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
print '='.red * (160 - line_count)
|
|
83
|
+
|
|
84
|
+
vertical_spacing 1
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def list_deals
|
|
88
|
+
extend CommandLineReporter
|
|
89
|
+
|
|
90
|
+
table(border: true) do
|
|
91
|
+
row do
|
|
92
|
+
column('No', width: 6, align: 'center')
|
|
93
|
+
column('Title', width: 94, padding: 2, align: 'center')
|
|
94
|
+
column('Price', width: 16, align: 'center')
|
|
95
|
+
column('Status', width: 31, align: 'center')
|
|
96
|
+
end
|
|
97
|
+
deals = SteamDailyDeals::Deal.all
|
|
98
|
+
|
|
99
|
+
deals.each.with_index(1) do |deal, i|
|
|
100
|
+
row do
|
|
101
|
+
column(i.to_s, color: 'cyan')
|
|
102
|
+
column(deal.name)
|
|
103
|
+
if deal.final_price.nil? || deal.final_price == ''
|
|
104
|
+
column('Free', color: 'red')
|
|
105
|
+
else
|
|
106
|
+
column(deal.final_price, color: 'red')
|
|
107
|
+
end
|
|
108
|
+
column(deal.availibility, color: 'green')
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
puts 'Please enter the number of the deal you wish to see more information about'
|
|
114
|
+
print 'You may also type list to see the list again or exit to quit: '
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def show_deal(index)
|
|
118
|
+
extend CommandLineReporter
|
|
119
|
+
|
|
120
|
+
vertical_spacing 2
|
|
121
|
+
|
|
122
|
+
deal_details = SteamDailyDeals::Deal.find_deal(index)
|
|
123
|
+
|
|
124
|
+
# Deal Title and Price
|
|
125
|
+
table(border: true) do
|
|
126
|
+
row do
|
|
127
|
+
column(deal_details.name, width: 143, align: 'center', color: 'cyan')
|
|
128
|
+
if deal_details.final_price.nil? || deal_details.final_price == ''
|
|
129
|
+
column('Free', width: 10, align: 'center', color: 'red')
|
|
130
|
+
else
|
|
131
|
+
column(deal_details.final_price, width: 10, align: 'center', color: 'red')
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Deal Description
|
|
137
|
+
table(border: true) do
|
|
138
|
+
row do
|
|
139
|
+
column(deal_details.description, width: 156)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Details
|
|
144
|
+
table(border: true) do
|
|
145
|
+
unless deal_details.release_date.nil?
|
|
146
|
+
row do
|
|
147
|
+
column('Release Date', width: 53, color: 'cyan')
|
|
148
|
+
column(deal_details.release_date, width: 100)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
unless deal_details.recent_rating.nil?
|
|
153
|
+
review_text = "#{deal_details.recent_rating} #{deal_details.recent_reviews}"
|
|
154
|
+
row do
|
|
155
|
+
column('Recent Reviews', width: 53, color: 'cyan')
|
|
156
|
+
if review_text.downcase.include?('positive')
|
|
157
|
+
column(review_text, width: 100, color: 'green')
|
|
158
|
+
elsif review_text.downcase.include?('negative')
|
|
159
|
+
column(review_text, width: 100, color: 'red')
|
|
160
|
+
else
|
|
161
|
+
column(review_text, width: 100, color: 'yellow')
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
unless deal_details.overall_rating.nil?
|
|
167
|
+
review_text = "#{deal_details.overall_rating} #{deal_details.total_reviews}"
|
|
168
|
+
row do
|
|
169
|
+
column('Overall Reviews', width: 53, color: 'cyan')
|
|
170
|
+
if review_text.downcase.include?('positive')
|
|
171
|
+
column(review_text, width: 100, color: 'green')
|
|
172
|
+
elsif review_text.downcase.include?('negative')
|
|
173
|
+
column(review_text, width: 100, color: 'red')
|
|
174
|
+
else
|
|
175
|
+
column(review_text, width: 100, color: 'yellow')
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
row do
|
|
181
|
+
column('Popular Tags', width: 53, color: 'cyan')
|
|
182
|
+
column(deal_details.popular_tags.join(", "), width: 100)
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
print "Please type list to get a list of today's deals or type exit to quit the program: ".cyan
|
|
187
|
+
end
|
|
188
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Deal Class
|
|
2
|
+
class SteamDailyDeals::Deal
|
|
3
|
+
attr_accessor :name,
|
|
4
|
+
:final_price,
|
|
5
|
+
:app_url,
|
|
6
|
+
:availibility,
|
|
7
|
+
:description,
|
|
8
|
+
:release_date,
|
|
9
|
+
:recent_rating,
|
|
10
|
+
:recent_reviews,
|
|
11
|
+
:overall_rating,
|
|
12
|
+
:total_reviews,
|
|
13
|
+
:popular_tags
|
|
14
|
+
|
|
15
|
+
@@all = []
|
|
16
|
+
|
|
17
|
+
def initialize(deal)
|
|
18
|
+
deal.each do |key, value|
|
|
19
|
+
send("#{key}=", value)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@@all << self
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.create_from_collection(deals)
|
|
26
|
+
deals.each { |deal| new(deal) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.find_deal(index)
|
|
30
|
+
self.all[index - 1]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def add_deal_information(deal_info)
|
|
34
|
+
deal_info.each do |key, value|
|
|
35
|
+
send("#{key}=", value)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.all
|
|
40
|
+
@@all
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Scraper class
|
|
2
|
+
class SteamDailyDeals::Scraper
|
|
3
|
+
def self.get_page(url)
|
|
4
|
+
browser = Selenium::WebDriver.for :phantomjs
|
|
5
|
+
browser.get url
|
|
6
|
+
|
|
7
|
+
if browser.page_source.include?('not be appropriate for all')
|
|
8
|
+
browser.find_element(:class, 'btn_grey_white_innerfade').click
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
if browser.page_source.include?('birth date')
|
|
12
|
+
dropdown = browser.find_element(:id, 'ageYear')
|
|
13
|
+
option = Selenium::WebDriver::Support::Select.new(dropdown)
|
|
14
|
+
option.select_by(:text, '1961')
|
|
15
|
+
option.select_by(:value, '1961')
|
|
16
|
+
browser.find_element(:class, 'btnv6_blue_hoverfade').click
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
page_contents = Nokogiri::HTML(browser.page_source)
|
|
20
|
+
browser.quit
|
|
21
|
+
page_contents
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.scrape_index_page(index_url = 'http://store.steampowered.com')
|
|
25
|
+
page = get_page(index_url).css('div.cluster_scroll_area')
|
|
26
|
+
page.each_with_object([]) do |card, arr|
|
|
27
|
+
card.css('a.cluster_capsule').each do |deal|
|
|
28
|
+
app_url = deal.attr('href').to_s
|
|
29
|
+
final_price = deal.css('.discount_final_price').text
|
|
30
|
+
availibility = deal.css('.main_cap_status').text
|
|
31
|
+
arr << { app_url: app_url, final_price: final_price, availibility: availibility }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.scrape_deal_page(page_url)
|
|
37
|
+
deal_page = get_page(page_url)
|
|
38
|
+
|
|
39
|
+
deal_info = {}
|
|
40
|
+
|
|
41
|
+
deal_info[:name] = deal_page.css('.apphub_AppName').text
|
|
42
|
+
|
|
43
|
+
unless deal_page.css('.game_description_snippet').nil?
|
|
44
|
+
deal_info[:description] = deal_page.css('.game_description_snippet').text.delete("\t").delete("\n")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
unless deal_page.css('.date').nil?
|
|
48
|
+
deal_info[:release_date] = deal_page.css('.date').text
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# The following code isn't very ruby-ish, but I've had a hard time trying
|
|
52
|
+
# to figure out how to grab these elements with nokogiri
|
|
53
|
+
# it's not the worst code ever, the double selector for the span's gets a
|
|
54
|
+
# little ugly and confusing for someone to read
|
|
55
|
+
# if deal_page.css('.subtitle').text.include?('Recent')
|
|
56
|
+
# deal_info[:recent_rating] = deal_page.search('div[text()="Recent:"] + span').text
|
|
57
|
+
# deal_info[:recent_reviews] = deal_page.search('div[text()="Recent:"] + span + span').text
|
|
58
|
+
# end
|
|
59
|
+
methodname(deal_page, deal_info, 'Recent')
|
|
60
|
+
methodname(deal_page, deal_info, 'Overall')
|
|
61
|
+
|
|
62
|
+
deal_info[:popular_tags] = deal_page.css('.popular_tags').children.css('a').map(&:text)
|
|
63
|
+
|
|
64
|
+
deal_info[:popular_tags].map { |tag| tag.delete!("\t").delete!("\n") }
|
|
65
|
+
|
|
66
|
+
deal_info
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def self.methodname(page, hash, option)
|
|
70
|
+
if page.css('.subtitle').text.include?(option)
|
|
71
|
+
hash[:overall_rating] = page.search('div[text()="' + option + ':"] + span').text
|
|
72
|
+
hash[:total_reviews] = page.search('div[text()="' + option + ':"] + span + span').text
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
data/spec.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Specifications for the CLI Assessment
|
|
2
|
+
|
|
3
|
+
Specs:
|
|
4
|
+
- [x] Have a CLI for interfacing with the application - I built the CLI to be as easy on the eyes as possible, while still maintaining full functionality of what I wanted. Behind the scenes some of the stuff might be a little ugly-ish when I'm using a heredoc to get the little artwork logo to display, but from the user standpoint it should be clean and easy to use. Users can type in list, a number or text to navigate through the available choices on our menu system.
|
|
5
|
+
- [x] Pull data from an external source - We are going out to http://store.steampowered.com and scraping the website using a mix of Selenium, PhantomJS and Nokogiri due to the complications with javascript's dynamic content on the steam's homepage. It ended up working out because we use Selenium to get past the age gates and mature content filters to scrape the information we need. I would have issues with this normally, but since we are not displaying any images nor should we be displaying any content that really should be not safe for work it should be ok. After scraping content from the homepage and each subsequent store page we load all of that into an array of hashes.
|
|
6
|
+
- [x] Implement both list and detail views - The user can type in list to get a list of all of today's deals scraped from the Steam homepage. They can also type in a number which allows them to look at any of the deals we have available and see the details of that game or program. Our detail view shows more information then the list view does by displaying things like a release date, reviews if available and the popular tags assigned to said game by the users and steam software.
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'steam_daily_deals/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'steam-daily-deals'
|
|
8
|
+
spec.version = SteamDailyDeals::VERSION
|
|
9
|
+
spec.authors = ['arturusfury']
|
|
10
|
+
spec.email = ['bri.reynolds@gmail.com']
|
|
11
|
+
|
|
12
|
+
spec.summary = 'Steam Daily Deal CLI Gem'
|
|
13
|
+
spec.description = "A CLI gem that goes out to grab today's deals from the steam homepage and allows the user to easily look through the details of each deal"
|
|
14
|
+
spec.homepage = 'https://github.com/arturusfury/steam_daily_deals'
|
|
15
|
+
spec.license = 'MIT'
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
18
|
+
spec.bindir = "exe"
|
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
20
|
+
spec.require_paths = ['lib']
|
|
21
|
+
|
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
|
25
|
+
spec.add_development_dependency 'nokogiri', '>= 0'
|
|
26
|
+
spec.add_development_dependency 'pry', '>= 0'
|
|
27
|
+
spec.add_development_dependency 'phantomjs', '>= 0'
|
|
28
|
+
spec.add_development_dependency 'headless', '>= 0'
|
|
29
|
+
spec.add_development_dependency 'watir-webdriver', '>= 0'
|
|
30
|
+
spec.add_development_dependency 'command_line_reporter', '>=3.0'
|
|
31
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: steam-daily-deals
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- arturusfury
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-08-01 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.12'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.12'
|
|
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.2'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.2'
|
|
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: :development
|
|
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: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: phantomjs
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: headless
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: watir-webdriver
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: command_line_reporter
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '3.0'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '3.0'
|
|
139
|
+
description: A CLI gem that goes out to grab today's deals from the steam homepage
|
|
140
|
+
and allows the user to easily look through the details of each deal
|
|
141
|
+
email:
|
|
142
|
+
- bri.reynolds@gmail.com
|
|
143
|
+
executables: []
|
|
144
|
+
extensions: []
|
|
145
|
+
extra_rdoc_files: []
|
|
146
|
+
files:
|
|
147
|
+
- ".gitignore"
|
|
148
|
+
- ".rspec"
|
|
149
|
+
- CODE_OF_CONDUCT.md
|
|
150
|
+
- Gemfile
|
|
151
|
+
- LICENSE.txt
|
|
152
|
+
- NOTES.md
|
|
153
|
+
- README.md
|
|
154
|
+
- Rakefile
|
|
155
|
+
- bin/console
|
|
156
|
+
- bin/setup
|
|
157
|
+
- bin/steam-daily-deals
|
|
158
|
+
- lib/steam_daily_deals.rb
|
|
159
|
+
- lib/steam_daily_deals/cli.rb
|
|
160
|
+
- lib/steam_daily_deals/deal.rb
|
|
161
|
+
- lib/steam_daily_deals/scraper.rb
|
|
162
|
+
- lib/steam_daily_deals/version.rb
|
|
163
|
+
- spec.md
|
|
164
|
+
- steam_daily_deals-0.1.0.gem
|
|
165
|
+
- steam_daily_deals.gemspec
|
|
166
|
+
homepage: https://github.com/arturusfury/steam_daily_deals
|
|
167
|
+
licenses:
|
|
168
|
+
- MIT
|
|
169
|
+
metadata: {}
|
|
170
|
+
post_install_message:
|
|
171
|
+
rdoc_options: []
|
|
172
|
+
require_paths:
|
|
173
|
+
- lib
|
|
174
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
|
+
requirements:
|
|
176
|
+
- - ">="
|
|
177
|
+
- !ruby/object:Gem::Version
|
|
178
|
+
version: '0'
|
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
|
+
requirements:
|
|
181
|
+
- - ">="
|
|
182
|
+
- !ruby/object:Gem::Version
|
|
183
|
+
version: '0'
|
|
184
|
+
requirements: []
|
|
185
|
+
rubyforge_project:
|
|
186
|
+
rubygems_version: 2.5.1
|
|
187
|
+
signing_key:
|
|
188
|
+
specification_version: 4
|
|
189
|
+
summary: Steam Daily Deal CLI Gem
|
|
190
|
+
test_files: []
|