vegas_insider_scraper 0.2.0 → 1.0.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 +4 -4
- data/lib/vegas_insider_scraper/mlb.rb +15 -0
- data/lib/vegas_insider_scraper/nba.rb +9 -0
- data/lib/vegas_insider_scraper/ncaabb.rb +9 -0
- data/lib/vegas_insider_scraper/ncaafb.rb +13 -0
- data/lib/vegas_insider_scraper/nfl.rb +9 -0
- data/lib/vegas_insider_scraper/nhl.rb +15 -0
- data/lib/{sports → vegas_insider_scraper}/scraper_league.rb +31 -24
- data/lib/vegas_insider_scraper/soccer.rb +90 -0
- data/lib/vegas_insider_scraper.rb +44 -20
- metadata +15 -16
- data/lib/sports/mlb.rb +0 -16
- data/lib/sports/nba.rb +0 -10
- data/lib/sports/ncaabb.rb +0 -22
- data/lib/sports/ncaafb.rb +0 -84
- data/lib/sports/nfl.rb +0 -10
- data/lib/sports/nhl.rb +0 -15
- data/lib/sports/soccer.rb +0 -89
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69a23eb646b9085eac798a97bc6cf733f98df54c21b3011371e4f4fa9f5a2252
|
4
|
+
data.tar.gz: bd8fbd9fccc62b419800a757191e232120657cfa02b48d9397dd34ff9479da3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 882881640914c68decd5b24d49343a73b4c2cb011d98f6bb2490866143dc80a28b5fca6bf069ca113ea0cf91298332e14bfb278d738ebca4d71bc8fd2b3d742f
|
7
|
+
data.tar.gz: 7f933d97c7ccabfc07e1186ea22ea27bc132c4ef7e6a0ccc55818ea80ee6e1192f73e3f45b71230877227dce5f4526dfcf015a98b763d577058697c8fbf6ca2d
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
module VegasInsiderScraper
|
3
|
+
class MLB < ScraperLeague
|
4
|
+
def initialize
|
5
|
+
@vegas_sport_identifier = 'mlb'
|
6
|
+
super
|
7
|
+
@moneyline_sport = true
|
8
|
+
end
|
9
|
+
|
10
|
+
def current_games
|
11
|
+
@current_games ||= get_lines(["http://www.vegasinsider.com/#{vegas_sport_identifier}/odds/las-vegas/run/",
|
12
|
+
"http://www.vegasinsider.com/#{vegas_sport_identifier}/odds/las-vegas/"])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
module VegasInsiderScraper
|
3
|
+
class NHL < ScraperLeague
|
4
|
+
def initialize
|
5
|
+
@vegas_sport_identifier = 'nhl'
|
6
|
+
super
|
7
|
+
@moneyline_sport = true
|
8
|
+
end
|
9
|
+
|
10
|
+
def current_games
|
11
|
+
@current_games ||= get_lines(["http://www.vegasinsider.com/#{vegas_sport_identifier}/odds/las-vegas/puck/",
|
12
|
+
"http://www.vegasinsider.com/#{vegas_sport_identifier}/odds/las-vegas/"])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -2,12 +2,14 @@ require 'nokogiri'
|
|
2
2
|
require 'open-uri'
|
3
3
|
|
4
4
|
class ScraperLeague
|
5
|
-
|
6
|
-
attr_reader :sport_id
|
7
|
-
attr_reader :sport_name
|
5
|
+
attr_reader :vegas_sport_identifier
|
8
6
|
attr_reader :moneyline_sport
|
9
7
|
attr_reader :teams
|
10
8
|
|
9
|
+
def sport_name
|
10
|
+
self.class.name.split('::').last.downcase
|
11
|
+
end
|
12
|
+
|
11
13
|
def initialize
|
12
14
|
@moneyline_sport = false
|
13
15
|
end
|
@@ -22,27 +24,31 @@ class ScraperLeague
|
|
22
24
|
|
23
25
|
# Gets the upcoming/current games for the sport
|
24
26
|
def current_games
|
25
|
-
@current_games ||= get_lines(["http://www.vegasinsider.com/#{
|
27
|
+
@current_games ||= get_lines(["http://www.vegasinsider.com/#{vegas_sport_identifier}/odds/las-vegas/","http://www.vegasinsider.com/#{vegas_sport_identifier}/odds/las-vegas/money/"])
|
26
28
|
end
|
27
29
|
|
28
30
|
# Gets all of the schedule and results for each team
|
29
31
|
def team_schedules
|
30
|
-
@team_schedules ||= teams.map
|
31
|
-
puts "
|
32
|
-
|
33
|
-
|
34
|
-
}
|
32
|
+
@team_schedules ||= teams.map do |team|
|
33
|
+
puts " >>>>>> GETTING GAMES FOR: #{team[:info][:full_name]}"
|
34
|
+
team_schedule_for(team[:info][:identifier])
|
35
|
+
end
|
35
36
|
end
|
36
37
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
38
|
+
def schedule_for(identifier)
|
39
|
+
url = "http://www.vegasinsider.com/#{vegas_sport_identifier}/teams/team-page.cfm/team/#{identifier}"
|
40
|
+
scrape_team_page(url, identifier)
|
40
41
|
end
|
41
42
|
|
43
|
+
# def live_scores
|
44
|
+
# @live_scores = get_live_scores("https://web.archive.org/web/20170704205945/http://www.vegasinsider.com/mlb/scoreboard/")
|
45
|
+
# nil
|
46
|
+
# end
|
47
|
+
|
42
48
|
private
|
43
49
|
|
44
50
|
def scrape_teams
|
45
|
-
url = "http://www.vegasinsider.com/#{
|
51
|
+
url = "http://www.vegasinsider.com/#{vegas_sport_identifier}/teams/"
|
46
52
|
doc = Nokogiri::HTML(open(url)).at_css('.main-content-cell')
|
47
53
|
|
48
54
|
doc.css('a').map do |team_link|
|
@@ -62,7 +68,7 @@ class ScraperLeague
|
|
62
68
|
# Gets the teams and scrapes the records for the teams
|
63
69
|
def scrape_standings
|
64
70
|
standings_teams = []
|
65
|
-
url = "http://www.vegasinsider.com/#{
|
71
|
+
url = "http://www.vegasinsider.com/#{vegas_sport_identifier}/standings/"
|
66
72
|
doc = Nokogiri::HTML(open(url)).at_css('.main-content-cell')
|
67
73
|
teams_doc = Nokogiri::HTML(open(url.gsub('standings','teams'))).at_css('.main-content-cell')
|
68
74
|
|
@@ -71,7 +77,7 @@ class ScraperLeague
|
|
71
77
|
next if conference_title.nil?
|
72
78
|
|
73
79
|
table = conference.css('.viBodyBorderNorm table')[standings_table_index]
|
74
|
-
table = conference.css('.viBodyBorderNorm table')[2] if (conference_title.content == 'Conference USA' &&
|
80
|
+
table = conference.css('.viBodyBorderNorm table')[2] if (conference_title.content == 'Conference USA' && vegas_sport_identifier == 'college-football')
|
75
81
|
|
76
82
|
if table
|
77
83
|
table.css('tr').each_with_index do |row, index|
|
@@ -86,13 +92,13 @@ class ScraperLeague
|
|
86
92
|
# Utility method for scraping standings
|
87
93
|
# * gets the standings table class
|
88
94
|
def standings_table_class
|
89
|
-
|
95
|
+
vegas_sport_identifier == "college-football" ? '.SLTables1' : 'table'
|
90
96
|
end
|
91
97
|
|
92
98
|
# Utility method for scraping standings
|
93
99
|
# * gets the index of the table
|
94
100
|
def standings_table_index
|
95
|
-
|
101
|
+
vegas_sport_identifier == "college-football" ? 1 : 0
|
96
102
|
end
|
97
103
|
|
98
104
|
# Utility method for scraping standings
|
@@ -110,19 +116,20 @@ class ScraperLeague
|
|
110
116
|
# Utility method for scraping standings
|
111
117
|
# * is a college sport?
|
112
118
|
def college_sport?
|
113
|
-
['college-football','college-basketball'].include?(
|
119
|
+
['college-football','college-basketball'].include?(vegas_sport_identifier)
|
114
120
|
end
|
115
121
|
|
116
122
|
# Utility method for scraping standings
|
117
123
|
# * scrapes a row of the standings, chooses a helper method based on the league
|
118
124
|
def scrape_standings_row(row, grouping, teams_doc)
|
119
125
|
team_shell = { info: {}, record: {} }
|
120
|
-
|
121
|
-
|
122
|
-
when
|
123
|
-
when
|
124
|
-
when
|
125
|
-
when
|
126
|
+
|
127
|
+
team = case vegas_sport_identifier
|
128
|
+
when 'college-football' then ncaafb_standings_row_parser(row, team_shell, teams_doc)
|
129
|
+
when 'college-basketball' then ncaabb_standings_row_parser(row, team_shell, teams_doc)
|
130
|
+
when 'nfl' then nfl_standings_row_parser(row, team_shell)
|
131
|
+
when 'mlb', 'nba' then pro_standings_row_parser(row, team_shell)
|
132
|
+
when 'nhl' then hockey_standings_row_parser(row, team_shell)
|
126
133
|
end
|
127
134
|
team[:grouping] = grouping
|
128
135
|
team
|
@@ -0,0 +1,90 @@
|
|
1
|
+
|
2
|
+
module VegasInsiderScraper
|
3
|
+
class Soccer < ScraperLeague
|
4
|
+
def initialize
|
5
|
+
@vegas_sport_identifier = 'soccer'
|
6
|
+
super
|
7
|
+
@moneyline_sport = true
|
8
|
+
end
|
9
|
+
|
10
|
+
def current_games
|
11
|
+
@current_games ||= get_lines([
|
12
|
+
"http://www.vegasinsider.com/#{vegas_sport_identifier}/odds/las-vegas/spread",
|
13
|
+
"http://www.vegasinsider.com/#{vegas_sport_identifier}/odds/las-vegas/"
|
14
|
+
])
|
15
|
+
end
|
16
|
+
|
17
|
+
def teams
|
18
|
+
[]
|
19
|
+
end
|
20
|
+
|
21
|
+
def standings
|
22
|
+
[]
|
23
|
+
end
|
24
|
+
|
25
|
+
def team_schedules
|
26
|
+
[]
|
27
|
+
end
|
28
|
+
|
29
|
+
def live_scores
|
30
|
+
[]
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def get_lines(urls)
|
36
|
+
games = []
|
37
|
+
|
38
|
+
urls.each { |url|
|
39
|
+
is_first_url = games.empty?
|
40
|
+
doc = Nokogiri::HTML(open(url))
|
41
|
+
doc.css('.viBodyBorderNorm .frodds-data-tbl tr').each do |game_row|
|
42
|
+
game_cell = game_row.at_css('td:first-child')
|
43
|
+
teams = game_cell_parser(game_cell)
|
44
|
+
game = Game.new(home_team: teams[1], away_team: teams[0])
|
45
|
+
|
46
|
+
if game.teams_found?
|
47
|
+
game.update(time: get_game_time(game_cell))
|
48
|
+
game.update(doubleheader: doubleheader_id(game_row.next&.next&.at_css('td:first-child')&.content))
|
49
|
+
is_first_url ? (games.push game) : (game = game.find_equal(games))
|
50
|
+
game.update(vegas_info: get_line(get_odds(game_row)))
|
51
|
+
|
52
|
+
elsif is_first_url
|
53
|
+
last_game = games.last
|
54
|
+
if last_game then last_game.update(notes: (last_game.notes ? "#{last_game.notes} / " : '') + game_cell.content) end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
}
|
58
|
+
games
|
59
|
+
end
|
60
|
+
|
61
|
+
def game_cell_parser(cell)
|
62
|
+
cell.css('b').map(&:content)
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_odds(odds_element)
|
66
|
+
(odds_element.at_css('td:nth-child(3)')&.content || '')
|
67
|
+
.gsub(' ', '')
|
68
|
+
.gsub(/[[:space:]]/, '')
|
69
|
+
.gsub('½','.5')
|
70
|
+
.gsub('¼', '.25')
|
71
|
+
.gsub('¾', '.75')
|
72
|
+
.strip
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_odds_inner_html(odds_element)
|
76
|
+
''
|
77
|
+
# ((odds_element.at_css('td:nth-child(3) a'))&.inner_html || '').encode('utf-8').gsub(" ","").gsub("½",".5").strip
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_line(odds_string)
|
81
|
+
odds_string = odds_string.gsub('PK', '-0')
|
82
|
+
result = matchdata_to_hash(RegularExpressions::SOCCER_MONEYLINE_ODDS.match(odds_string) ||
|
83
|
+
RegularExpressions::SOCCER_ODDS.match(odds_string))
|
84
|
+
|
85
|
+
|
86
|
+
result.each { |k,v| result[k] = result[k].to_s.to_f if result[k] }
|
87
|
+
get_home_and_away(result)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -2,27 +2,51 @@ require 'nokogiri'
|
|
2
2
|
require 'open-uri'
|
3
3
|
# require 'byebug'
|
4
4
|
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
require '
|
10
|
-
require '
|
11
|
-
require '
|
12
|
-
require '
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
5
|
+
require 'vegas_insider_scraper/scraper_league'
|
6
|
+
require 'vegas_insider_scraper/ncaafb'
|
7
|
+
require 'vegas_insider_scraper/ncaabb'
|
8
|
+
require 'vegas_insider_scraper/nba'
|
9
|
+
require 'vegas_insider_scraper/nfl'
|
10
|
+
require 'vegas_insider_scraper/mlb'
|
11
|
+
require 'vegas_insider_scraper/nhl'
|
12
|
+
require 'vegas_insider_scraper/soccer'
|
13
|
+
|
14
|
+
module VegasInsiderScraper
|
15
|
+
SPORTS = [
|
16
|
+
VegasInsiderScraper::NCAAFB,
|
17
|
+
VegasInsiderScraper::NCAABB,
|
18
|
+
VegasInsiderScraper::NFL,
|
19
|
+
VegasInsiderScraper::NBA,
|
20
|
+
VegasInsiderScraper::MLB,
|
21
|
+
VegasInsiderScraper::NHL,
|
22
|
+
VegasInsiderScraper::Soccer
|
23
|
+
]
|
24
|
+
|
25
|
+
def self.ncaafb
|
26
|
+
VegasInsiderScraper::NCAAFB.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.ncaabb
|
30
|
+
VegasInsiderScraper::NCAABB.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.nfl
|
34
|
+
VegasInsiderScraper::NFL.new
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.nba
|
38
|
+
VegasInsiderScraper::NBA.new
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.mlb
|
42
|
+
VegasInsiderScraper::MLB.new
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.nhl
|
46
|
+
VegasInsiderScraper::NHL.new
|
21
47
|
end
|
22
48
|
|
23
|
-
|
24
|
-
|
25
|
-
@sports.select { |sport| sport.class == sport_class }.first
|
26
|
-
end
|
49
|
+
def self.soccer
|
50
|
+
VegasInsiderScraper::Soccer.new
|
27
51
|
end
|
28
52
|
end
|
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: 0.
|
4
|
+
version: 1.0.0
|
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-03-
|
11
|
+
date: 2019-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -38,22 +38,22 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description: A
|
42
|
-
|
41
|
+
description: A web scraping gem for teams, betting lines, records, and results for
|
42
|
+
the NCAA (football and basketball), NFL, NBA, MLB, NHL, and Soccer
|
43
43
|
email: reitz1994@gmail.com
|
44
44
|
executables: []
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- lib/sports/mlb.rb
|
49
|
-
- lib/sports/nba.rb
|
50
|
-
- lib/sports/ncaabb.rb
|
51
|
-
- lib/sports/ncaafb.rb
|
52
|
-
- lib/sports/nfl.rb
|
53
|
-
- lib/sports/nhl.rb
|
54
|
-
- lib/sports/scraper_league.rb
|
55
|
-
- lib/sports/soccer.rb
|
56
48
|
- lib/vegas_insider_scraper.rb
|
49
|
+
- lib/vegas_insider_scraper/mlb.rb
|
50
|
+
- lib/vegas_insider_scraper/nba.rb
|
51
|
+
- lib/vegas_insider_scraper/ncaabb.rb
|
52
|
+
- lib/vegas_insider_scraper/ncaafb.rb
|
53
|
+
- lib/vegas_insider_scraper/nfl.rb
|
54
|
+
- lib/vegas_insider_scraper/nhl.rb
|
55
|
+
- lib/vegas_insider_scraper/scraper_league.rb
|
56
|
+
- lib/vegas_insider_scraper/soccer.rb
|
57
57
|
homepage: https://github.com/mreitz94/betting-tools-scraper
|
58
58
|
licenses:
|
59
59
|
- MIT
|
@@ -73,10 +73,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
|
-
|
77
|
-
rubygems_version: 2.7.9
|
76
|
+
rubygems_version: 3.0.1
|
78
77
|
signing_key:
|
79
78
|
specification_version: 4
|
80
|
-
summary: A
|
81
|
-
and
|
79
|
+
summary: A web scraping gem for teams, betting lines, records, and results for the
|
80
|
+
NCAA (football and basketball), NFL, NBA, MLB, NHL, and Soccer
|
82
81
|
test_files: []
|
data/lib/sports/mlb.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
class MLB < ScraperLeague
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@sport_id = 4
|
6
|
-
@sport_name = :mlb
|
7
|
-
super
|
8
|
-
@moneyline_sport = true
|
9
|
-
end
|
10
|
-
|
11
|
-
def current_games
|
12
|
-
@current_games ||= get_lines(["http://www.vegasinsider.com/#{sport_name}/odds/las-vegas/run/",
|
13
|
-
"http://www.vegasinsider.com/#{sport_name}/odds/las-vegas/"])
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
data/lib/sports/nba.rb
DELETED
data/lib/sports/ncaabb.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
|
2
|
-
class NCAABB < ScraperLeague
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@sport_id = 1
|
6
|
-
@sport_name = 'college-basketball'
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
10
|
-
# def get_nicknames
|
11
|
-
# start_time = Time.now
|
12
|
-
# num_successes = 0
|
13
|
-
# Team.ncaabb_teams.each_with_index do |team, i|
|
14
|
-
# url = "http://www.vegasinsider.com/college-basketball/teams/team-page.cfm/team/#{team.vegas_insider_identifier}"
|
15
|
-
# nickname = Scraper.scrape_team_page_for_nickname(team.vegas_insider_identifier, url)
|
16
|
-
# team.nickname = nickname
|
17
|
-
# team.save
|
18
|
-
# end
|
19
|
-
# Time.now - start_time
|
20
|
-
# end
|
21
|
-
|
22
|
-
end
|
data/lib/sports/ncaafb.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
|
2
|
-
class NCAAFB < ScraperLeague
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@sport_id = 0
|
6
|
-
@sport_name = 'college-football'
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
10
|
-
def teams
|
11
|
-
@teams ||= scrape_teams
|
12
|
-
end
|
13
|
-
|
14
|
-
# def get_nicknames
|
15
|
-
# start_time = Time.now
|
16
|
-
# Team.where(sport_id: 0).each_with_index do |team, i|
|
17
|
-
# next if team.nickname
|
18
|
-
# url = "http://www.vegasinsider.com/college-football/teams/team-page.cfm/team/#{team.vegas_insider_identifier}"
|
19
|
-
# nickname = Scraper.scrape_team_page_for_nickname(team.vegas_insider_identifier, url)
|
20
|
-
# team.nickname = nickname
|
21
|
-
# team.save
|
22
|
-
# end
|
23
|
-
# Time.now - start_time
|
24
|
-
# end
|
25
|
-
|
26
|
-
# def get_locations
|
27
|
-
# start_time = Time.now
|
28
|
-
# Team.where(sport_id: 0, custom_team_flag: 1).each_with_index do |team, i|
|
29
|
-
# team.location = nil
|
30
|
-
# team.save
|
31
|
-
# end
|
32
|
-
# Time.now - start_time
|
33
|
-
# end
|
34
|
-
|
35
|
-
# def scrape_custom_team_page_for_location(vegas_identifier, url)
|
36
|
-
# doc = Nokogiri::HTML(open(url))
|
37
|
-
# title = doc.at_css('h1.page_title').content.gsub(' Team Page', '')
|
38
|
-
# return title
|
39
|
-
# end
|
40
|
-
|
41
|
-
# def remove_nickname_from_location
|
42
|
-
# start_time = Time.now
|
43
|
-
# Team.where(sport_id: 0).each_with_index do |team, i|
|
44
|
-
# puts team.location
|
45
|
-
# puts team.location.gsub(" #{team.nickname}", '')
|
46
|
-
# end
|
47
|
-
# Time.now - start_time
|
48
|
-
# end
|
49
|
-
|
50
|
-
# def scrape_fcs_teams
|
51
|
-
# url = 'http://www.vegasinsider.com/college-football/teams/'
|
52
|
-
# doc = Nokogiri::HTML(open(url))
|
53
|
-
|
54
|
-
# current_conference = nil
|
55
|
-
# fcs = []
|
56
|
-
|
57
|
-
# doc.css('.main-content-cell table table table').each_with_index do |col,i|
|
58
|
-
# col.css('tr').each do |row|
|
59
|
-
# new_conference = row.at_css('td.viSubHeader1')
|
60
|
-
|
61
|
-
# if new_conference
|
62
|
-
# current_conference = new_conference.content
|
63
|
-
# else
|
64
|
-
# team = row.at_css('a')
|
65
|
-
# if team
|
66
|
-
# team_formatted = {
|
67
|
-
# team_name: team.content,
|
68
|
-
# team_url_id: team_url_parser(team.attribute('href')),
|
69
|
-
# conference: current_conference,
|
70
|
-
# league: sport_id
|
71
|
-
# }
|
72
|
-
# puts team_formatted
|
73
|
-
# fcs.push team_formatted
|
74
|
-
# end
|
75
|
-
# end
|
76
|
-
# end
|
77
|
-
# end
|
78
|
-
|
79
|
-
# Team.save_teams(fcs)
|
80
|
-
# return true
|
81
|
-
|
82
|
-
# end
|
83
|
-
|
84
|
-
end
|
data/lib/sports/nfl.rb
DELETED
data/lib/sports/nhl.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
class NHL < ScraperLeague
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@sport_id = 5
|
6
|
-
@sport_name = :nhl
|
7
|
-
super
|
8
|
-
@moneyline_sport = true
|
9
|
-
end
|
10
|
-
|
11
|
-
def current_games
|
12
|
-
@current_games ||= get_lines(["http://www.vegasinsider.com/#{sport_name}/odds/las-vegas/puck/",
|
13
|
-
"http://www.vegasinsider.com/#{sport_name}/odds/las-vegas/"])
|
14
|
-
end
|
15
|
-
end
|
data/lib/sports/soccer.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
|
2
|
-
class Soccer < ScraperLeague
|
3
|
-
def initialize
|
4
|
-
@sport_id = 9
|
5
|
-
@sport_name = :soccer
|
6
|
-
super
|
7
|
-
@moneyline_sport = true
|
8
|
-
end
|
9
|
-
|
10
|
-
def current_games
|
11
|
-
@current_games ||= get_lines([
|
12
|
-
"http://www.vegasinsider.com/#{sport_name}/odds/las-vegas/spread",
|
13
|
-
"http://www.vegasinsider.com/#{sport_name}/odds/las-vegas/"
|
14
|
-
])
|
15
|
-
end
|
16
|
-
|
17
|
-
def teams
|
18
|
-
[]
|
19
|
-
end
|
20
|
-
|
21
|
-
def standings
|
22
|
-
[]
|
23
|
-
end
|
24
|
-
|
25
|
-
def team_schedules
|
26
|
-
[]
|
27
|
-
end
|
28
|
-
|
29
|
-
def live_scores
|
30
|
-
[]
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def get_lines(urls)
|
36
|
-
games = []
|
37
|
-
|
38
|
-
urls.each { |url|
|
39
|
-
is_first_url = games.empty?
|
40
|
-
doc = Nokogiri::HTML(open(url))
|
41
|
-
doc.css('.viBodyBorderNorm .frodds-data-tbl tr').each do |game_row|
|
42
|
-
game_cell = game_row.at_css('td:first-child')
|
43
|
-
teams = game_cell_parser(game_cell)
|
44
|
-
game = Game.new(home_team: teams[1], away_team: teams[0])
|
45
|
-
|
46
|
-
if game.teams_found?
|
47
|
-
game.update(time: get_game_time(game_cell))
|
48
|
-
game.update(doubleheader: doubleheader_id(game_row.next&.next&.at_css('td:first-child')&.content))
|
49
|
-
is_first_url ? (games.push game) : (game = game.find_equal(games))
|
50
|
-
game.update(vegas_info: get_line(get_odds(game_row)))
|
51
|
-
|
52
|
-
elsif is_first_url
|
53
|
-
last_game = games.last
|
54
|
-
if last_game then last_game.update(notes: (last_game.notes ? "#{last_game.notes} / " : '') + game_cell.content) end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
}
|
58
|
-
games
|
59
|
-
end
|
60
|
-
|
61
|
-
def game_cell_parser(cell)
|
62
|
-
cell.css('b').map(&:content)
|
63
|
-
end
|
64
|
-
|
65
|
-
def get_odds(odds_element)
|
66
|
-
(odds_element.at_css('td:nth-child(3)')&.content || '')
|
67
|
-
.gsub(' ', '')
|
68
|
-
.gsub(/[[:space:]]/, '')
|
69
|
-
.gsub('½','.5')
|
70
|
-
.gsub('¼', '.25')
|
71
|
-
.gsub('¾', '.75')
|
72
|
-
.strip
|
73
|
-
end
|
74
|
-
|
75
|
-
def get_odds_inner_html(odds_element)
|
76
|
-
''
|
77
|
-
# ((odds_element.at_css('td:nth-child(3) a'))&.inner_html || '').encode('utf-8').gsub(" ","").gsub("½",".5").strip
|
78
|
-
end
|
79
|
-
|
80
|
-
def get_line(odds_string)
|
81
|
-
odds_string = odds_string.gsub('PK', '-0')
|
82
|
-
result = matchdata_to_hash(RegularExpressions::SOCCER_MONEYLINE_ODDS.match(odds_string) ||
|
83
|
-
RegularExpressions::SOCCER_ODDS.match(odds_string))
|
84
|
-
|
85
|
-
|
86
|
-
result.each { |k,v| result[k] = result[k].to_s.to_f if result[k] }
|
87
|
-
get_home_and_away(result)
|
88
|
-
end
|
89
|
-
end
|