Created
August 31, 2009 14:05
-
-
Save janv/178470 to your computer and use it in GitHub Desktop.
Gamespot Grabber
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
#!/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