Skip to content

Instantly share code, notes, and snippets.

@pdfrod
Last active December 16, 2015 11:09
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 pdfrod/5425666 to your computer and use it in GitHub Desktop.
Save pdfrod/5425666 to your computer and use it in GitHub Desktop.
Scrapes the list of contestants in Portugal from the Google Code Jam 2013 Qualification Round
require 'open-uri'
require 'json'
MAXPOS = 21261
STEP = 20
def getUrl(pos)
"http://code.google.com/codejam/contest/2270488/scoreboard/do/?cmd=GetScoreboard&start_pos=#{pos}"
end
contestants = (1..MAXPOS).step(STEP).flat_map do |i|
$stderr.puts "Reading page #{i}"
open(getUrl(i)) do |f|
json = JSON.parse(f.read)
json['rows'].find_all {|row| row['c'] == 'Portugal'}
end
end
contestants.each do |c|
puts "#{c['r']} #{c['n']}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment