vegas_insider_scraper 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vegas_insider_scraper/scraper_league.rb +28 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5da344d3fb972c1628fa835f561628049aba8ea84684a78bb50333d8da9ba3ee
|
4
|
+
data.tar.gz: 8314442a6678a6da65cca3bb7d8a5edf12647d9e99d88f80bdc0c249c2563e26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fc9c3974ad506865f610e18e7ccef4c99f7d6630757ef7e8f08ff7ac060870e4f2dc0153dcd7341e31838d78d74078a47402ef8e241c515a9ee0e75d6e50a7a
|
7
|
+
data.tar.gz: bab62fa2f08f7e84d55c653d08706d3c1958a413dabe98d064ff9807809e2b1f5557debdf6e475f83120889381060265c25b8f682f217b497ba2c7b754ac3d51
|
@@ -52,7 +52,7 @@ class ScraperLeague
|
|
52
52
|
doc = Nokogiri::HTML(open(url)).at_css('.main-content-cell')
|
53
53
|
|
54
54
|
doc.css('a').map do |team_link|
|
55
|
-
|
55
|
+
team = {}
|
56
56
|
team[:info] = format_college_team(team_link, doc)
|
57
57
|
|
58
58
|
row = team_link.parent.parent.previous
|
@@ -92,7 +92,7 @@ class ScraperLeague
|
|
92
92
|
# Utility method for scraping standings
|
93
93
|
# * gets the standings table class
|
94
94
|
def standings_table_class
|
95
|
-
vegas_sport_identifier == "college-football" ? '.SLTables1' : 'table'
|
95
|
+
vegas_sport_identifier == "college-football" ? '.SLTables1' : 'table'
|
96
96
|
end
|
97
97
|
|
98
98
|
# Utility method for scraping standings
|
@@ -141,7 +141,7 @@ class ScraperLeague
|
|
141
141
|
row.css('td').each_with_index do |cell, cell_index|
|
142
142
|
value = remove_element_whitespace(cell)
|
143
143
|
case cell_index
|
144
|
-
when 0
|
144
|
+
when 0
|
145
145
|
team[:info] = format_college_team(cell.at_css('a'), teams_doc)
|
146
146
|
when 1 then team[:record][:conf_wins] = value.to_i
|
147
147
|
when 2 then team[:record][:conf_losses] = value.to_i
|
@@ -162,11 +162,11 @@ class ScraperLeague
|
|
162
162
|
row.css('td').each_with_index do |cell, cell_index|
|
163
163
|
value = remove_element_whitespace(cell)
|
164
164
|
case cell_index
|
165
|
-
when 0
|
165
|
+
when 0
|
166
166
|
team[:info] = format_college_team(cell.at_css('a'), teams_doc)
|
167
167
|
when 1 then team[:record][:overall_wins] = value.to_i
|
168
168
|
when 2 then team[:record][:overall_losses] = value.to_i
|
169
|
-
when 5
|
169
|
+
when 5
|
170
170
|
record = RegularExpressions::RECORD_REGEX.match(value) || { wins: 0, losses: 0 }
|
171
171
|
team[:record][:home_wins] = record[:wins].to_i
|
172
172
|
team[:record][:home_losses] = record[:losses].to_i
|
@@ -219,7 +219,7 @@ class ScraperLeague
|
|
219
219
|
when 0 then team[:info] = format_team(cell.at_css('a'))
|
220
220
|
when 1 then team[:record][:overall_wins] = content.to_i
|
221
221
|
when 2 then team[:record][:overall_losses] = content.to_i
|
222
|
-
when 5
|
222
|
+
when 5
|
223
223
|
record = RegularExpressions::RECORD_REGEX.match(content) || { wins: 0, losses: 0 }
|
224
224
|
team[:record][:home_wins] = record[:wins]
|
225
225
|
team[:record][:home_losses] = record[:losses]
|
@@ -237,7 +237,7 @@ class ScraperLeague
|
|
237
237
|
def hockey_standings_row_parser(row, team)
|
238
238
|
row.css('td').each_with_index do |cell, cell_index|
|
239
239
|
content = remove_element_whitespace(cell)
|
240
|
-
|
240
|
+
|
241
241
|
case cell_index
|
242
242
|
when 0 then team[:info] = format_team(cell.at_css('a'))
|
243
243
|
when 1 then team[:record][:overall_wins] = content.to_i
|
@@ -245,7 +245,7 @@ class ScraperLeague
|
|
245
245
|
when 3 then team[:record][:over_time_losses] = content.to_i
|
246
246
|
when 4 then team[:record][:shootout_losses] = content.to_i
|
247
247
|
when 5 then team[:record][:points] = content.to_i
|
248
|
-
when 8
|
248
|
+
when 8
|
249
249
|
record = RegularExpressions::NHL_RECORD_REGEX.match(content) || { wins: 0, losses: 0, ot_losses: 0, shootout_losses: 0 }
|
250
250
|
team[:record][:home_wins] = record[:wins]
|
251
251
|
team[:record][:home_losses] = record[:losses]
|
@@ -267,7 +267,7 @@ class ScraperLeague
|
|
267
267
|
def format_team(url)
|
268
268
|
full_name = url.content
|
269
269
|
identifier = team_url_parser(url.attribute('href'))
|
270
|
-
nickname = humanize_identifier(identifier)
|
270
|
+
nickname = humanize_identifier(identifier)[0]
|
271
271
|
|
272
272
|
{
|
273
273
|
identifier: identifier,
|
@@ -287,7 +287,10 @@ class ScraperLeague
|
|
287
287
|
nickname = full_name.gsub("#{location} ",'')
|
288
288
|
|
289
289
|
if nickname == full_name
|
290
|
-
nickname = full_name.gsub('&','')
|
290
|
+
nickname = full_name.gsub('&','')
|
291
|
+
.gsub(humanize_identifier(identifier)[0], '')
|
292
|
+
.gsub(humanize_identifier(identifier)[1], '')
|
293
|
+
.strip
|
291
294
|
end
|
292
295
|
|
293
296
|
if nickname == full_name.gsub('&','').strip
|
@@ -296,17 +299,22 @@ class ScraperLeague
|
|
296
299
|
nickname = nickname_exceptions(identifier,nickname)
|
297
300
|
end
|
298
301
|
|
302
|
+
location = full_name.gsub(" #{nickname}", '')
|
303
|
+
|
299
304
|
return {
|
300
305
|
identifier: identifier,
|
301
306
|
nickname: nickname,
|
302
|
-
location:
|
307
|
+
location: location,
|
303
308
|
full_name: full_name,
|
304
309
|
url: url.attribute('href').value
|
305
310
|
}
|
306
311
|
end
|
307
312
|
|
308
313
|
def humanize_identifier(identifier)
|
309
|
-
|
314
|
+
[
|
315
|
+
identifier.split('-').map(&:capitalize).join(' '),
|
316
|
+
identifier.split('-').map(&:capitalize).join('-')
|
317
|
+
]
|
310
318
|
end
|
311
319
|
|
312
320
|
def nickname_exceptions(identifier,nickname)
|
@@ -346,7 +354,7 @@ class ScraperLeague
|
|
346
354
|
|
347
355
|
result = {}
|
348
356
|
game.css('.tanBg a').each_with_index do |team, i|
|
349
|
-
if i == 0
|
357
|
+
if i == 0
|
350
358
|
result[:away_team] = team_url_parser(team.attribute('href'))
|
351
359
|
else
|
352
360
|
result[:home_team] = team_url_parser(team.attribute('href'))
|
@@ -386,8 +394,8 @@ class ScraperLeague
|
|
386
394
|
end
|
387
395
|
|
388
396
|
if segment_titles
|
389
|
-
result[:scoring] = segment_titles.each_with_index.map { |s,i|
|
390
|
-
{ period: s, away: away_values[i], home: home_values[i] }
|
397
|
+
result[:scoring] = segment_titles.each_with_index.map { |s,i|
|
398
|
+
{ period: s, away: away_values[i], home: home_values[i] }
|
391
399
|
}
|
392
400
|
end
|
393
401
|
|
@@ -419,7 +427,7 @@ class ScraperLeague
|
|
419
427
|
|
420
428
|
game_cell = game_row.at_css('td:first-child')
|
421
429
|
teams = game_cell_parser(game_cell)
|
422
|
-
game = Game.new(home_team: teams[1], away_team: teams[0])
|
430
|
+
game = Game.new(home_team: teams[1], away_team: teams[0])
|
423
431
|
|
424
432
|
if game.teams_found?
|
425
433
|
game.update(time: get_game_time(game_cell))
|
@@ -514,7 +522,7 @@ class ScraperLeague
|
|
514
522
|
|
515
523
|
case m
|
516
524
|
when 0 then game.update(time: get_game_date(cell,row))
|
517
|
-
when 1
|
525
|
+
when 1
|
518
526
|
info = get_game_info(cell, team)
|
519
527
|
opponent = info[:opponent]
|
520
528
|
game.update(info[:game_info])
|
@@ -559,7 +567,7 @@ class ScraperLeague
|
|
559
567
|
# * determines if the game has concluded
|
560
568
|
def game_finished?(row)
|
561
569
|
!"#{RegularExpressions::GAME_RESULTS.match(remove_element_whitespace(row.at_css('td:nth-child(5)')))}".empty?
|
562
|
-
end
|
570
|
+
end
|
563
571
|
|
564
572
|
# Utility method for scraping team page results
|
565
573
|
# * gets the home_team, away_team, and doubleheader info
|
@@ -641,7 +649,7 @@ class ScraperLeague
|
|
641
649
|
SOCCER_MONEYLINE_ODDS = /(?<away_moneyline>(-|\+)\d+)(?<home_moneyline>(-|\+)\d+)(?<draw>(-|\+)\d+)(?<over_under>\d((\.5)|(\.25)|(\.75))?)(o|u).\d\d/
|
642
650
|
RUNLINE_ODDS = /(?<away_line>(\+|-)\d+(\.5)?)\/(\+|-)\d{3}(?<home_line>(\+|-)\d+(\.5)?)\/(\+|-)\d{3}/
|
643
651
|
MONEYLINE_ODDS = /((?<over_under>\d+(\.5)?)[ou]-\d{2})?(?<away_moneyline>(\+|-)\d{3}\d*)(?<home_moneyline>(\+|-)\d{3}\d*)/
|
644
|
-
|
652
|
+
|
645
653
|
DOUBLEHEADER = /DH Gm (?<id>\d)/
|
646
654
|
RESULTS_DOUBLEHEADER = /\(DH (?<doubleheader>\d)\)/
|
647
655
|
|
@@ -659,7 +667,7 @@ class ScraperLeague
|
|
659
667
|
end
|
660
668
|
|
661
669
|
def update(args = {})
|
662
|
-
Game.sanitize(args).map { |attribute, value|
|
670
|
+
Game.sanitize(args).map { |attribute, value|
|
663
671
|
new_val = (attribute == :vegas_info && value && vegas_info) ? value.merge(vegas_info) : value
|
664
672
|
instance_variable_set("@#{attribute}", new_val)
|
665
673
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vegas_insider_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Reitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|