vegas_insider_scraper 0.1.5 → 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 +4 -4
- data/lib/sports/scraper_league.rb +6 -2
- data/lib/sports/soccer.rb +89 -0
- data/lib/vegas_insider_scraper.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d913d3440b91317653dc9fd161e9b9a5474cc7dfd80012682c74c9f6a2bb9e6
|
4
|
+
data.tar.gz: 43b029b0436db2dcf18bf472cf9784521b5546b8aaf383ab4a10b9fa2c36d618
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 120c346e644548e23676daa0f4a264a75bcf9a12396e1510272239f96a4da832f41f2e8b460b5d2bb65cfa8eba944a7eaeee21c6e0251d4a6fdd31a38418c755
|
7
|
+
data.tar.gz: a2ed206492830f2b4e11ba348ef443ea5f608efa719a4764e0b06b2dfcb30d29a4cd170bc3690f8bedff769a1c33dab016cbc9f15a9f575907bcd95ecf3bb2a9
|
@@ -630,6 +630,8 @@ class ScraperLeague
|
|
630
630
|
ODDS = /(<br><br>(?<home_line>-\d+(\.5)?))|(<br>(?<away_line>-\d+(\.5)?)[+-]\d\d<br>)|
|
631
631
|
((?<over_under>\d+(\.5)?)[ou]((-\d{2})|EV)(?<home_line>-\d+(.5)?)-\d\d\z)|
|
632
632
|
((?<away_line>-\d+(.5)?)-\d\d(?<over_under>\d+(\.5)?)[ou]((-\d{2})|EV)\z)/x
|
633
|
+
SOCCER_ODDS = /(?<away_line>(-|\+)?((-0)|(\d|\.)+))(((\+|-)\d\d)|(EV))(?<home_line>(-|\+)?((-0)|(\d|\.)+))(((\+|-)\d\d)|(EV))/
|
634
|
+
SOCCER_MONEYLINE_ODDS = /(?<away_moneyline>(-|\+)\d+)(?<home_moneyline>(-|\+)\d+)(?<draw>(-|\+)\d+)(?<over_under>\d((\.5)|(\.25)|(\.75))?)(o|u).\d\d/
|
633
635
|
RUNLINE_ODDS = /(?<away_line>(\+|-)\d+(\.5)?)\/(\+|-)\d{3}(?<home_line>(\+|-)\d+(\.5)?)\/(\+|-)\d{3}/
|
634
636
|
MONEYLINE_ODDS = /((?<over_under>\d+(\.5)?)[ou]-\d{2})?(?<away_moneyline>(\+|-)\d{3}\d*)(?<home_moneyline>(\+|-)\d{3}\d*)/
|
635
637
|
|
@@ -642,7 +644,8 @@ class ScraperLeague
|
|
642
644
|
|
643
645
|
class Game
|
644
646
|
attr_reader :time, :away_team, :home_team, :vegas_info,
|
645
|
-
:ending, :winning_team, :winning_score, :losing_score,
|
647
|
+
:ending, :winning_team, :winning_score, :losing_score,
|
648
|
+
:ats_winner, :over_under_result, :doubleheader, :notes
|
646
649
|
|
647
650
|
def initialize(args = {})
|
648
651
|
Game.sanitize(args).map { |attribute, value| instance_variable_set("@#{attribute}", value) }
|
@@ -682,7 +685,8 @@ class ScraperLeague
|
|
682
685
|
private
|
683
686
|
def self.sanitize(args)
|
684
687
|
permitted_keys = [:time, :away_team, :home_team, :vegas_info,
|
685
|
-
:ending, :winning_team, :winning_score, :losing_score,
|
688
|
+
:ending, :winning_team, :winning_score, :losing_score,
|
689
|
+
:ats_winner, :over_under_result, :doubleheader, :notes]
|
686
690
|
args.select { |key,_| permitted_keys.include? key }
|
687
691
|
end
|
688
692
|
end
|
@@ -0,0 +1,89 @@
|
|
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
|
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: 0.2.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-
|
11
|
+
date: 2019-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/sports/nfl.rb
|
53
53
|
- lib/sports/nhl.rb
|
54
54
|
- lib/sports/scraper_league.rb
|
55
|
+
- lib/sports/soccer.rb
|
55
56
|
- lib/vegas_insider_scraper.rb
|
56
57
|
homepage: https://github.com/mreitz94/betting-tools-scraper
|
57
58
|
licenses:
|
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
74
|
version: '0'
|
74
75
|
requirements: []
|
75
76
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.7.
|
77
|
+
rubygems_version: 2.7.9
|
77
78
|
signing_key:
|
78
79
|
specification_version: 4
|
79
80
|
summary: A gem to scrape the web for sports statistics, teams, betting lines, records,
|