Created
April 15, 2012 20:44
-
-
Save owenkellogg/2394738 to your computer and use it in GitHub Desktop.
automator for login to wellsfargo
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
require 'mechanize' | |
require 'open-uri' | |
module WellsFargo | |
SIGNIN_URI = URI 'https://www.wellsfargo.com' | |
class Authenticator | |
attr_reader :agent, :account_page, :signin_form, :username_field, :password_field, :submit_button | |
def initialize username, password | |
@username, @password = username, password | |
@agent = Mechanize.new do |agent| | |
agent.follow_meta_refresh = true | |
agent.user_agent_alias = 'Mac Safari' | |
end | |
@signin_page = @agent.get WellsFargo::SIGNIN_URI | |
@signin_form = @signin_page.forms.select {|f| f.name == "signon" }.first | |
@username_field = @signin_form.fields.select {|f| f.name == 'userid' }.first | |
@password_field = @signin_form.fields.select {|f| f.name == 'password' }.first | |
@submit_button = @signin_form.buttons.select {|b| b.name = "btnSignon" }.first | |
end | |
def signin | |
@username_field.value = @username | |
@password_field.value = @password | |
@signin_form.submit | |
# Submitting the form takes us to a page with a javascript for refresh, so we want to manually | |
# fetch that page to view our account: | |
@account_page = @agent.get 'https://online.wellsfargo.com/das/cgi-bin/session.cgi?screenid=SIGNON_PORTAL_PAUSE' | |
end | |
def cash_balance | |
page = signin | |
div = page.parser.css '#cashTotalAvailBalance' | |
div.children.first.text.strip | |
end | |
end | |
end | |
if ARGV.length == 2 | |
wf = WellsFargo::Authenticator::new ARGV[0], ARGV[1] | |
puts | |
puts "********* Wells Fargo Account for #{ ARGV[0] } *********" | |
puts | |
puts " Cash Balance = #{ wf.cash_balance }" | |
puts | |
puts | |
else | |
puts "You must specify your Wells Fargo username and password as the two command line arguments" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a command-line utility for checking on your Wells Fargo bank account.