Created
August 13, 2010 00:40
-
-
Save stevencorona/522031 to your computer and use it in GitHub Desktop.
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
desc "collect balances from bank of america" | |
task :bank_of_america => :environment do | |
Mechanize.html_parser = Nokogiri::HTML | |
agent = Mechanize.new | |
agent.user_agent_alias = "Windows IE 7" | |
balances = nil | |
agent.get("https://sitekey.bankofamerica.com/sas/signon.do?state=NY") do |page| | |
username_form_result = page.form_with(:name => "signonForm") do |first_login| | |
first_login.onlineID = CREDENTIALS["bank_of_america"]["username"] | |
end.submit | |
sitekey_page = agent.get('https://sitekey.bankofamerica.com/sas/signon.do?&detect=5') | |
sitekey_form_result = sitekey_page.form_with(:name => "challengeQandAForm") do |second_login| | |
second_login.sitekeyChallengeAnswer = CREDENTIALS["bank_of_america"]["sitekey"] | |
end.submit | |
dashboard = sitekey_form_result.form_with(:name => "verifyImageForm") do |third_login| | |
third_login.passcode = CREDENTIALS["bank_of_america"]["password"] | |
end.submit | |
balances = dashboard.search("//span[@class='text2-mbna acctOvrwText']") | |
end | |
type = 1 | |
balances.each do |balance| | |
string_b = balance.children.text.to_s | |
string_b['$'] = ''; | |
string_b[','] = ''; | |
float_b = Float(string_b) | |
object = BoaBalance.new | |
object.balance = float_b | |
object.type = type | |
object.save | |
type += 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment