Created
May 19, 2011 15:34
-
-
Save theirix/981050 to your computer and use it in GitHub Desktop.
Tracks a ticket in macsolutions.ru
This file contains 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'mechanize' | |
require 'nokogiri' | |
unless ARGV.size == 2 | |
STDERR.puts "$0 trackid last-four-phone-digits" | |
exit 1 | |
end | |
Mechanize.new.get('http://service.macsolutions.ru/track') do |page| | |
track_page = page.form_with(:action => '/requests/show') do |f| | |
f.id = ARGV[0] | |
f.password = ARGV[1] | |
end.click_button | |
Nokogiri::HTML(track_page.body, 'UTF-8').xpath("//tr[starts-with(@id, 'stage')]").each do |item| | |
date = item.search('td/text()')[0].text.strip | |
what = item.search('td/strong/text()')[0].text.strip | |
comm = item.search('td/div/text()')[0].text.strip | |
puts "#{date}: #{what}; #{comm}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment