Skip to content

Instantly share code, notes, and snippets.

@owenkellogg
Created April 15, 2012 20:44
Show Gist options
  • Save owenkellogg/2394738 to your computer and use it in GitHub Desktop.
Save owenkellogg/2394738 to your computer and use it in GitHub Desktop.
automator for login to wellsfargo
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
@owenkellogg
Copy link
Author

This is a command-line utility for checking on your Wells Fargo bank account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment