Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require "httparty"
- require "nokogiri"
- $stdout.sync = true
- class ChallengesSolves
- def initialize
- @root = Nokogiri::HTML(HTTParty.get("https://www.rankk.org/"))
- @levels = @root.css("#hofs > ul > li").flat_map do |level|
- group = level.css("img")[0]["alt"][/\d+/]
- level.css("li a").map{|a| ["#{group}/#{a.text}", a["href"]] }
- end.to_h
- end
- def call
- @levels.each do |id, path|
- doc = Nokogiri::HTML(HTTParty.get("https://www.rankk.org#{path}"))
- solves = doc.css("td.td")[0].text
- puts [id, solves].join("\t")
- end
- end
- end
- ChallengesSolves.new.call
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement