Created
June 5, 2014 21:11
-
-
Save joshmn/f4eb8797939da1dadfb1 to your computer and use it in GitHub Desktop.
MLB Draft 2014: If teams were comprised solely of players they drafted (results of each team)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
require 'nokogiri' | |
page = HTTParty.get('http://www.brewcrewball.com/2014/6/5/5328814/mlb-draft-players-roster-construction-brewers-yankees-red-sox-dodgers') | |
doc = Nokogiri::HTML(page.body) | |
i = 0 | |
doc.css('#article-body h3').each do |t| | |
next if t.text.empty? | |
team = t.text | |
trs = doc.css('#article-body table')[i].css('tr') | |
rwar = 0.0 | |
trs.each do |t| | |
if t.css('td')[0].text == "Position" | |
else | |
rwar += t.css('td').last.text.to_f | |
end | |
end | |
puts "#{team}: #{rwar.round}" | |
i += 1 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment