-
-
Save thexdesk/5aacbd2a1738c1b876f2ac32599cc0f3 to your computer and use it in GitHub Desktop.
Wells Fargo Automation
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 'io/console' | |
| require 'mechanize' | |
| agent = Mechanize.new | |
| # http://curl.haxx.se/ca/cacert.pem | |
| agent.ca_file = 'cacert.pem' | |
| puts 'Connecting to Wells Fargo...' | |
| page = agent.get 'https://wellsfargo.com' | |
| puts 'Enter your credentials (the characters will not show)' | |
| puts 'Username:' | |
| userid = STDIN.noecho(&:gets).strip | |
| puts 'Password:' | |
| password = STDIN.noecho(&:gets).strip | |
| begin | |
| puts 'Signing in...' | |
| form = page.form 'signon' | |
| form.userid = userid | |
| form.password = password | |
| agent.submit form | |
| page = agent.get 'https://online.wellsfargo.com/das/cgi-bin/session.cgi?screenid=SIGNON_PORTAL_PAUSE' | |
| cash = page.search '//table[@id="cash"]' | |
| strip = lambda{ |x| x.to_s.strip } | |
| # Getting first text element to avoid text after <span> | |
| title_list = cash.search('//tbody/tr/th/a/text()[1]').map &strip | |
| balance_list = cash.search('//tbody/tr/td/a/text()').map &strip | |
| balances = Hash[title_list.zip balance_list] | |
| max_length = title_list.map(&:length).max | |
| append_spaces = lambda{ |x| x + ' '*(max_length - x.length) } | |
| # Table heading | |
| puts | |
| puts "#{append_spaces.call 'Account'} | Balance" | |
| puts '-'*max_length + '-+' + '-'*10 | |
| # Table rows | |
| balances.each do |k, v| | |
| puts "#{append_spaces.call k} | #{v}" | |
| end | |
| # This part is incomplete...trying to download the activity file. | |
| page = agent.click(page.link_with(text: /Account Activity/)) | |
| page = agent.click(page.link_with(text: /Download Activity/)) | |
| form = page.form 'DownloadFormBean' | |
| form.radiobutton_with(name: /commaDelimited/).check | |
| agent.submit form | |
| ensure | |
| puts | |
| puts 'Signing out...' | |
| agent.get 'https://online.wellsfargo.com/das/channel/signoff' | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment