Advertisement
t_a_w

rankk get solve numbers

Oct 29th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.63 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. require "httparty"
  4. require "nokogiri"
  5.  
  6. $stdout.sync = true
  7.  
  8. class ChallengesSolves
  9.   def initialize
  10.     @root = Nokogiri::HTML(HTTParty.get("https://www.rankk.org/"))
  11.     @levels = @root.css("#hofs > ul > li").flat_map do |level|
  12.       group = level.css("img")[0]["alt"][/\d+/]
  13.       level.css("li a").map{|a| ["#{group}/#{a.text}", a["href"]] }
  14.     end.to_h
  15.   end
  16.  
  17.   def call
  18.     @levels.each do |id, path|
  19.       doc = Nokogiri::HTML(HTTParty.get("https://www.rankk.org#{path}"))
  20.       solves = doc.css("td.td")[0].text
  21.       puts [id, solves].join("\t")
  22.     end
  23.   end
  24. end
  25.  
  26. ChallengesSolves.new.call
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement