Skip to content

Instantly share code, notes, and snippets.

@mharris717
Created January 16, 2015 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mharris717/6de050317b7aed9a1c86 to your computer and use it in GitHub Desktop.
Save mharris717/6de050317b7aed9a1c86 to your computer and use it in GitHub Desktop.
scrape.rb
require 'open-uri'
require 'nokogiri'
def links
res = []
doc = Nokogiri::HTML(open("http://www.perfectgame.org/Rankings/Players/Default.aspx?gyear=2015&num=500"))
doc.css("tr.ranking_row, tr.ranking_alt_row").each do |row|
row.css("td:eq(4) a").each do |link|
res << link.attr('href')
end
end
res
end
puts links.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment