Created
March 31, 2010 14:41
-
-
Save kmarsh/350412 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'mechanize' | |
if ARGV.size != 2 | |
puts "Usage: #{$0} ups_username ups_password" | |
exit 1 | |
end | |
a = Mechanize.new do |agent| | |
agent.user_agent_alias = 'Mac Safari' | |
agent.read_timeout = 360 | |
agent.open_timeout = 360 | |
end | |
a.get('http://ups.com/') do |page| | |
country_select = page.form_with(:name => 'frmCountry') do |country_select_form| | |
country_select_form['cookie'] = "us_en_home" | |
end.submit | |
login = country_select.form_with(:action => 'https://wwwapps.ups.com/cclamp/login') do |login_form| | |
login_form['userid'] = ARGV[0] | |
login_form['password'] = ARGV[1] | |
end.submit | |
qvd = a.click(login.link_with(:text => /Quantum View Data/)) | |
file = qvd.form_with(:name => "srsForm") do |file_form| | |
file_form['s'] = "CBC1B72F6BFC9E94" # 3: Outbound, 4: Third Party, CBC1B72F6BFC9E94: Rev | |
file_form['e'] = "3" # All Files | |
file_form['buttonNameValue'] = "_downloadall_" | |
end.submit | |
puts file.body | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment