Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
MLB Draft 2014: If teams were comprised solely of players they drafted (results of each team)
require 'httparty'
require 'nokogiri'
page = HTTParty.get('')
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"
rwar += t.css('td').last.text.to_f
puts "#{team}: #{rwar.round}"
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment