Skip to content

Instantly share code, notes, and snippets.

@BlaneCordes
Created July 25, 2012 02:43
Show Gist options
  • Save BlaneCordes/3174077 to your computer and use it in GitHub Desktop.
Save BlaneCordes/3174077 to your computer and use it in GitHub Desktop.
scrape
def self.scrape_free_agents
transaction_trends_page = Nokogiri::HTML(open("http://baseball.fantasysports.yahoo.com/b1/buzzindex?date=#{Time.now.to_date}&pos=ALL&src=combined&sort=BI_A&sdir=1"))
hot_players = transaction_trends_page.css(".name").text
hot_players.gsub!(/([A-Z][^A-Z]+)/, '\1 ')
hot_players.gsub!(/([A-Z])/, '\1\2')
hot_players.gsub!(/(Shin-|O') /, '\1')
hot_players.gsub!(/(Wei-|O') /, '\1')
array_players = hot_players.split(' ')
array_players.each_with_index do |name,index|
if name == "CC"
next
elsif name == "Ty"
next
elsif name.length <= 2
array_players[index] = "#{name} " + "#{array_players[index+1]}"
array_players.delete_at(index+1)
end
end
array_players.each_with_index do |player,index|
@free_agent = FreeAgent.new
if index.even?
@free_agent.first_name = player
@free_agent.last_name = array_players[index+1]
elsif player == "De"
array_players[i] = "De Aza"
next
end
if @free_agent.first_name == nil
next
end
@free_agent.save
end
end
end
@igrabes
Copy link

igrabes commented Jul 25, 2012

remove what you added and after the "next" on line 27 put an "else" with a "next" in it and end it. That should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment