Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I use this to send txt messages to my cell when my Paypal balance changes.
#!/usr/bin/perl # silent11 # 11/16/2004 use strict; use warnings; my $paypal_email = ""; my $paypal_pass = ""; my $notify_from = ""; my $notify_to = ""; my $balance_file = "balance.txt"; my $balance = return_balance(); # # # Get notified via email (or cell phone txt msg) # # # of Paypal balance changes notify_me( $balance ) if compare( $balance ); # # # Subs # # # sub return_balance { use WWW::Mechanize; my $browser = WWW::Mechanize->new(); $browser->get("https://www.paypal.com/"); $browser->form(1); $browser->field("login_email", $paypal_email); $browser->field("login_password", $paypal_pass); $browser->click(); $browser->follow("click here to reload"); my $html = $browser->content; # Please don't laugh at the regex ;^) It works! $html =~ /(.*history">\$)(\d+\.\d+) (USD)/s; return $2; } sub compare { use Tie::File; # First time to use Tie::File # very cool! tie my @balance, 'Tie::File', $balance_file || die $!; my $new_balance = shift; my $cur_balance = $balance[0]; $balance[0] = $new_balance; untie @balance; return 1 if ($new_balance != $cur_balance); } sub notify_me { use MIME::Lite; my $msg = MIME::Lite->new( From => $notify_from, To => $notify_to, Subject => 'Paypal Balance', Data => $balance ); $msg->send || die $!; }

Update: changed http to https per zentra's suggestion.



-silent11
Spread Firefox

In reply to Get notified of Paypal balance changes by silent11

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-24 02:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found