Skip to content

Instantly share code, notes, and snippets.

@takkaw
Created May 2, 2012 15:03
Show Gist options
  • Select an option

  • Save takkaw/2577252 to your computer and use it in GitHub Desktop.

Select an option

Save takkaw/2577252 to your computer and use it in GitHub Desktop.
AtCoder lanking
# encoding : utf-8
# usdge : ruby ac_lank.rb num user_name
# example : ruby ac_lank.rb 002 takkaw
require 'nokogiri'
require 'open-uri'
arc = ARGV.shift.to_i
url = "http://arc%03d.contest.atcoder.jp/standings/" % arc
user = "/users/" + ARGV.shift
xpath = "//div[@id='outer-inner' and @class='container']/table[@class='table table-bordered table-striped']"
25.times { |t|
doc = Nokogiri::HTML(open(url + (t+1).to_s))
users = doc.xpath(xpath)[0].xpath(".//td/a")
users.each_with_index { |td,i|
if td[:href] == user
puts t*20 + i + 1
exit
end
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment