Created
October 8, 2009 06:26
-
-
Save sigmike/204805 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' | |
require 'pp' | |
def url_for(path) | |
base = "http://example.com/" | |
base + path | |
end | |
h = WWW::Mechanize.new | |
h.get url_for("login.php") do |login| | |
form = login.forms.first | |
form.login = "my_login" | |
form.pass = "my_password" | |
page = h.submit(form, form.buttons.first) | |
suffix = Time.now.strftime("-%Y%m%d_%H%M%S.csv") | |
page = h.get url_for("tracking.php") | |
File.open("tracking#{suffix}", "w") do |f| | |
f.write page.body | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment