class UriMiner
Public Class Methods
config(email: "", password: "", name: "")
click to toggle source
# File lib/uri_miner/login.rb, line 6 def self.config(email: "", password: "", name: "") @name = name @email = email @password = password end
exercise(id)
click to toggle source
# File lib/uri_miner/exercise.rb, line 4 def self.exercise(id) url = "https://www.urionlinejudge.com.br/judge/en/problems/view/#{id}" page = @agent.get(url) iframe = @agent.click page.iframes.first { name: iframe.search(".header h1").text, content: iframe.search(".problem").to_html, category: page.search("#page-name-c ul li")[0].text[2..-1].strip, level: page.search("#page-name-c ul li")[2].text[2..-1].strip[6..-1], limit_time: page.search("#page-name-c ul li")[6].text[2..-1].strip[17..-1].split[0], limit_mem: page.search("#page-name-c ul li")[8].text[2..-1].strip[14..-1].split[0] } end
login(email: @email, password: @password)
click to toggle source
# File lib/uri_miner/login.rb, line 12 def self.login(email: @email, password: @password) @agent.get("https://www.urionlinejudge.com.br/judge/pt/login") form = @agent.page.forms.first form.field_with(name: "email").value = email form.field_with(name: "password").value = password form.submit form.buttons.first end
submit(code: "", id: 1001, lang: 5)
click to toggle source
# File lib/uri_miner/code.rb, line 4 def self.submit(code: "", id: 1001, lang: 5) @agent.get("https://www.urionlinejudge.com.br/judge/pt/runs/add") form = @agent.page.forms.first form.field_with(name: "language_id").value = lang form.field_with(name: "problem_id").value = id form.field_with(name: "source_code").value = code form.submit form.buttons.first result end
Private Class Methods
result()
click to toggle source
this is shit
# File lib/uri_miner/code.rb, line 19 def self.result result = "- In queue -" while result.include?("- In queue -") sleep(1) @agent.get("https://www.urionlinejudge.com.br/judge/pt/runs/live") page = @agent.page rows = page.css("div#element table tr") rows.each do |row| name = row.css("td.wide a").text result = row.css("td.semi-wide.answer.aw").text break if name == @name end break end result.squeeze(" ") end