Advertisement
saasbook

Clipper card example

Jan 22nd, 2012
5,437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.57 KB | None | 0 0
  1. require 'mechanize'
  2.  
  3. def get_clipper_value()
  4.   # local variables
  5.   url = 'https://clippercard.com/ClipperWeb/login.do'
  6.   username = 'xxx@xxx.com'
  7.   password = 'xxx'
  8.   # notice method chaining:
  9.   amount =
  10.     Mechanize.new.
  11.     # note passing of hash argument
  12.     post(url, :username => username, :password => password).
  13.     # not use of regular expression as hash value
  14.     link_with(:href => /cardValue/i).
  15.     click.
  16.     parser.xpath("//tr/td[contains(.,'Clipper Cash')]").first.
  17.     next_sibling.next_sibling.
  18.     content.match(/\$(\d+\.\d+)/)
  19.   html($1)
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement