nfl_fantasy_scraper 0.0.1 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nfl_fantasy_scraper.rb +37 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9628f761adea1376b6327e075b2874571eeb5ac8
|
4
|
+
data.tar.gz: 4187efa1f84fc400fae11548dd6d8558503f1ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a34ab49e0729db6a673716c33b2630854d63113fdfbdc22c83d3f580859be064927b521ffc9edf1311bfcbfd29e82ded9ef9ea3c78d5e832848813ea7d3586
|
7
|
+
data.tar.gz: 8fe98fbe9ba392c2dfd5ea247d883b7e6d4ba942210ab932878f1ab0569437bd90ac81fc4e59d2b29b19402ed941f5a631c6a24af300f9fd0386a045ca6bc59c
|
data/lib/nfl_fantasy_scraper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mechanize'
|
2
|
+
require 'terminal-table'
|
2
3
|
|
3
4
|
NFL_URL = "#{ENV['NFL_URL']}"
|
4
5
|
NFL_PWD = "#{ENV['NFL_PWD']}"
|
@@ -22,7 +23,19 @@ class NFLFantasyScraper
|
|
22
23
|
@page = @mechanize.get(NFL_PP)
|
23
24
|
end
|
24
25
|
|
26
|
+
def print_table
|
27
|
+
rows = []
|
28
|
+
my_team.each do |player|
|
29
|
+
rows << [player[0], player[1][0], player[1][1]]
|
30
|
+
end
|
31
|
+
table = Terminal::Table.new :headings => ['Player', 'Opponent', 'Current Points'], :rows => rows
|
32
|
+
end
|
33
|
+
|
25
34
|
def my_team
|
35
|
+
Hash[my_team_player_names.zip(join_stats)]
|
36
|
+
end
|
37
|
+
|
38
|
+
def my_team_player_names
|
26
39
|
team_page = @mechanize.get(NFL_URL)
|
27
40
|
|
28
41
|
players = team_page.search('.tableType-player .playerNameAndInfo').map do |td|
|
@@ -31,6 +44,24 @@ class NFLFantasyScraper
|
|
31
44
|
players - [" ", nil, "Offense", "Defense Team", "Kicker"]
|
32
45
|
end
|
33
46
|
|
47
|
+
def scrape_opponents
|
48
|
+
team_page = @mechanize.get(NFL_URL)
|
49
|
+
|
50
|
+
opponents = team_page.search('.tableType-player .playerOpponent').map do |td|
|
51
|
+
td.text
|
52
|
+
end
|
53
|
+
opponents - [" ", nil, "Opp"]
|
54
|
+
end
|
55
|
+
|
56
|
+
def scrape_points
|
57
|
+
team_page = @mechanize.get(NFL_URL)
|
58
|
+
|
59
|
+
points = team_page.search('.tableType-player .statTotal').map do |td|
|
60
|
+
td.text
|
61
|
+
end
|
62
|
+
points - [" ", nil, "Points"]
|
63
|
+
end
|
64
|
+
|
34
65
|
def available_players
|
35
66
|
players = []
|
36
67
|
|
@@ -43,6 +74,12 @@ class NFLFantasyScraper
|
|
43
74
|
players.flatten - [" ", nil]
|
44
75
|
end
|
45
76
|
|
77
|
+
private
|
78
|
+
|
79
|
+
def join_stats
|
80
|
+
scrape_opponents.zip(scrape_points)
|
81
|
+
end
|
82
|
+
|
46
83
|
def next_page
|
47
84
|
link = @page.link_with(text: '>')
|
48
85
|
@page = link.click
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nfl_fantasy_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Andersen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A webscraper for NFL.com Fantasy Football
|
14
14
|
email: ianderse@mac.com
|