Skip to content

Instantly share code, notes, and snippets.

@theirix
Created May 19, 2011 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theirix/981050 to your computer and use it in GitHub Desktop.
Save theirix/981050 to your computer and use it in GitHub Desktop.
Tracks a ticket in macsolutions.ru
#!/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