vegas_insider_scraper 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d913d3440b91317653dc9fd161e9b9a5474cc7dfd80012682c74c9f6a2bb9e6
4
- data.tar.gz: 43b029b0436db2dcf18bf472cf9784521b5546b8aaf383ab4a10b9fa2c36d618
3
+ metadata.gz: 69a23eb646b9085eac798a97bc6cf733f98df54c21b3011371e4f4fa9f5a2252
4
+ data.tar.gz: bd8fbd9fccc62b419800a757191e232120657cfa02b48d9397dd34ff9479da3b
5
5
  SHA512:
6
- metadata.gz: 120c346e644548e23676daa0f4a264a75bcf9a12396e1510272239f96a4da832f41f2e8b460b5d2bb65cfa8eba944a7eaeee21c6e0251d4a6fdd31a38418c755
7
- data.tar.gz: a2ed206492830f2b4e11ba348ef443ea5f608efa719a4764e0b06b2dfcb30d29a4cd170bc3690f8bedff769a1c33dab016cbc9f15a9f575907bcd95ecf3bb2a9
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,9 @@
1
+
2
+ module VegasInsiderScraper
3
+ class NBA < ScraperLeague
4
+ def initialize
5
+ @vegas_sport_identifier = 'nba'
6
+ super
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+
2
+ module VegasInsiderScraper
3
+ class NCAABB < ScraperLeague
4
+ def initialize
5
+ @vegas_sport_identifier = 'college-basketball'
6
+ super
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+
2
+ module VegasInsiderScraper
3
+ class NCAAFB < ScraperLeague
4
+ def initialize
5
+ @vegas_sport_identifier = 'college-football'
6
+ super
7
+ end
8
+
9
+ def teams
10
+ @teams ||= scrape_teams
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+
2
+ module VegasInsiderScraper
3
+ class NFL < ScraperLeague
4
+ def initialize
5
+ @vegas_sport_identifier = 'nfl'
6
+ super
7
+ end
8
+ end
9
+ 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/#{sport_name}/odds/las-vegas/","http://www.vegasinsider.com/#{sport_name}/odds/las-vegas/money/"])
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 { |team|
31
- puts " ### GETTING GAMES FOR: #{team[:info][:full_name]}"
32
- url = "http://www.vegasinsider.com/#{sport_name}/teams/team-page.cfm/team/#{team[:info][:identifier]}"
33
- scrape_team_page(url, team[:info][:identifier])
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 live_scores
38
- @live_scores = get_live_scores("https://web.archive.org/web/20170704205945/http://www.vegasinsider.com/mlb/scoreboard/")
39
- nil
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/#{sport_name}/teams/"
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/#{sport_name}/standings/"
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' && sport_name == 'college-football')
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
- sport_name == "college-football" ? '.SLTables1' : 'table'
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
- sport_name == "college-football" ? 1 : 0
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?(sport_name)
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
- team = case sport_id
121
- when 0 then ncaafb_standings_row_parser(row, team_shell, teams_doc)
122
- when 1 then ncaabb_standings_row_parser(row, team_shell, teams_doc)
123
- when 2 then nfl_standings_row_parser(row, team_shell)
124
- when 3,4 then pro_standings_row_parser(row, team_shell)
125
- when 5 then hockey_standings_row_parser(row, team_shell)
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 'sports/scraper_league'
6
- require 'sports/ncaafb'
7
- require 'sports/ncaabb'
8
- require 'sports/nba'
9
- require 'sports/nfl'
10
- require 'sports/mlb'
11
- require 'sports/nhl'
12
- require 'sports/soccer'
13
-
14
- class VegasInsiderScraper
15
- attr_reader :sports
16
-
17
- SPORTS = [NCAAFB, NCAABB, NFL, NBA, MLB, NHL]
18
-
19
- def initialize
20
- @sports = SPORTS.map { |sport_class| sport_class.new }
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
- SPORTS.each do |sport_class|
24
- define_method(sport_class.to_s.downcase) do
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.2.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-08 00:00:00.000000000 Z
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 gem to scrape the web for sports statistics, teams, betting lines,
42
- records, and results!
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
- rubyforge_project:
77
- rubygems_version: 2.7.9
76
+ rubygems_version: 3.0.1
78
77
  signing_key:
79
78
  specification_version: 4
80
- summary: A gem to scrape the web for sports statistics, teams, betting lines, records,
81
- and results!
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
@@ -1,10 +0,0 @@
1
-
2
- class NBA < ScraperLeague
3
-
4
- def initialize
5
- @sport_id = 3
6
- @sport_name = :nba
7
- super
8
- end
9
-
10
- end
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
@@ -1,10 +0,0 @@
1
-
2
- class NFL < ScraperLeague
3
-
4
- def initialize
5
- @sport_id = 2
6
- @sport_name = :nfl
7
- super
8
- end
9
-
10
- end
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