Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- user = 'USERNAME HERE'
- pass = 'PASSWORD HERE'
- security_answers = {
- 'What was the color of your first car?' => 'XXX',
- 'What was the name of your first boyfriend?' => 'XXX',
- 'What was the first bone you broke?' => 'XXX'
- }
- agent = Mechanize.new
- login_form = agent.get('https://www.ucard.chase.com/').form_with(:name => 'form1')
- login_form.userId = user
- login_form.password = pass
- result = agent.submit(login_form)
- # if it forces us to validate security question, do so
- if (security_question_form =
- result.form_with(:action => '/authenticate_isSecurityAnswerValid.action'))
- question =
- result.parser.xpath('//td[@class="cdpLeftAlignedTdLabel"]').first.text.strip
- security_question_form.securityAnswer = security_answers[question]
- result = agent.submit(security_question_form)
- end
- # ok, now we should be on main login page
- today = Date.today
- # when will balance expire? on 10th of each month.
- exp_month = if today.day < 10 then today.month else 1+today.month end
- exp_date = Date.civil(today.year, exp_month, 10)
- days_left = (exp_date - today).to_i
- message = " will be forfeited on #{exp_date.strftime('%b %e')} (in #{days_left} days)"
- html { (result.body =~ /\$\s*(\d+\.\d\d)/ ? $1 : '???') + message }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement