#!/usr/bin/perl use strict; # of course use warnings; # for sanity use WWW::Mechanize; # form automation use HTML::TableExtract; # fetch table column data # Sneaky hack to allow 302's to be followed { no warnings; *WWW::Mechanize::redirect_ok; } my $pp = WWW::Mechanize->new(); # Broken into bits for reuse my $site = "https://www.paypal.com/cgi-bin"; my $login = "$site/webscr?__track=_login-run:p"; my $submit = "$site/$login/gen/login:_login-submit"; # Fetch the main page $pp->get($submit); # Enter your PayPal email address to log in here $pp->field('login_email', 'foo@bar.org'); # PayPal password that matches the above email $pp->field('login_password', '0bscur3d'); # Submit the above data to the form $pp->click("submit.x"); # Fetch the history page my $page_one = $pp->get("$site/webscr?cmd=_history"); # Select "Payments Sent to $project". This key below # isn't real but in your normal PayPal HTML source, a key # very similar to it will be real, so use that one instead. # # Look for a field that resembles something like the one # below, if you have multiple email addresses registered # with PayPal, that is, if not, use the regular item field. $pp->field('item', '6:ige6R1ps_M9LEaOxaG7_p1tq_h8-9Li00'); # Checkmark (radio button) for "Within" $pp->field('span', 'broad'); # Last "x" in dropdown. 1=Day, 2=Week, 3=Month, 4=Year $pp->field('for', '4'); # Send it my $results = $pp->click("submit.x"); # Fetch the columns out of the tables get_donations($results); ########################################### # # Process the donations, print the results # ########################################### sub get_donations { my $results = shift; my $te = new HTML::TableExtract(headers=> [ 'Date', 'To/From', 'Name/Email', 'Gross\(\$\)', 'Fee\(\$\)', 'Net Amount\(\$\)']); $te->parse($results->{_content}); foreach my $ts ($te->table_states) { my ($gross_total, $net_total); # Limit to only payments Received, # not payments made FROM PayPal for my $row (grep $_->[1] !~ /To/, $ts->rows) { # Remove leading and trailing # spaces from array members. They # show up as   in the HTML and # HTML::TableExtract makes them # spaces tr/\240/ /, s/^\s+//, s/\s+$// foreach @$row; # Map scalars to table header names my ($date, # Donation date $to_from, # Was it To/From $name, # Donator $donation, # Gross donation $paypal_fee, # PayPal's cut $net_amount, # Net after cut ) = @$row[0 .. 6]; print "Date.......: $date\n"; print "Name.......: $name\n"; print "Donation...: $donation\n"; print "Net Amount.: $net_amount\n\n"; $gross_total += $donation; $net_total += $net_amount; } $gross_total = sprintf("%.02f", $gross_total); print "Total donations...: \$$gross_total\n"; $net_total = sprintf("%.02f", $net_total); print "Net after Paypal..: \$$net_total\n\n"; } }

In reply to SlurpPal v1.0 by hacker

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.