Skip to content

Instantly share code, notes, and snippets.

@janv
Created August 31, 2009 14:05
Show Gist options
  • Save janv/178470 to your computer and use it in GitHub Desktop.
Save janv/178470 to your computer and use it in GitHub Desktop.
Gamespot Grabber
#!/bin/env ruby
url = 'www.gamespot.com/games.html?type=games&mode=all&sort=score&dlx_type=all&sortdir=asc&sortdir=asc&page='
re = /<td class="tac"><a href="[\d\w\/]*index.html">(\d\d?.\d)<\/a><\/td>/im
# Init Scores
scores = {}
(0..10).each do |t|
(0..9).each do |o|
scores["#{t}.#{o}"] = 0
end
end
# Scrape
(0..164).each do |n|
puts "Scanning page #{n}"
page = `curl -s -c ~/curlcookies.dat \"#{url}#{n}\"`
page.scan(re).each { |m| scores[m[0]] = scores[m[0]] + 1 }
end
# Output
scores.sort.each do |s|
puts "#{s[0]} : #{s[1]}" unless s[1] == 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment