Last active
July 24, 2016 20:22
-
-
Save poctek/2d61db88732ba8a56a91cea0e48a67c1 to your computer and use it in GitHub Desktop.
Script to check my application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "mechanize" | |
require "open-uri" | |
agent = Mechanize.new | |
page = agent.get("http://abiturient.kpfu.ru/entrant/abit_entrant_originals_list?p_open=&p_faculty=47&p_speciality=375&p_inst=0&p_typeofstudy=1") | |
table = page.search("body table tr") | |
result = table.select { |tr| tr.attributes["style"].to_s == "font-weight:bold;"} | |
puts "Names with originals: " | |
my_place = 0 | |
result.each_with_index do |tr, index| | |
td = tr.search("td") | |
puts "#{td[1].children.text} || #{td[3].children.text}" | |
my_place = index if td[1].children.text == "Катин Ростислав Максимович" | |
end | |
puts "\nTotal applications count: #{table.length - 6}" | |
puts "Applications with originals count: #{result.length}" | |
if my_place == 0 | |
puts "I'm still not in list" | |
else | |
puts "My place is: #{my_place}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment