#!/usr/bin/perl #displays paypal.com account activity for time interval use LWP; use HTTP::Cookies; if ($#ARGV==-1) { print "Usage: scrap_paypal accountno 2004-01-01 2004-12-31\n"; exit 1; } print STDERR "Please enter password\n"; system "stty -echo"; #mask passwd chomp($passwd=); system "stty echo"; my $from_a = substr($ARGV[1],5,2); my $from_b = substr($ARGV[1],8,2); my $from_c = substr($ARGV[1],0,4); my $to_a = substr($ARGV[2],5,2); my $to_b = substr($ARGV[2],8,2); my $to_c = substr($ARGV[2],0,4); my $browser = LWP::UserAgent->new(); $browser->env_proxy( ); # if we're behind a firewall my $cookie_jar = HTTP::Cookies->new(); #login, part 1, get a cookie my $response = $browser->get ('https://www.paypal.com'); $cookie_jar->extract_cookies($response); $browser->cookie_jar ( $cookie_jar ); #login, part 2, send auth data my $response = $browser->post ('https://www.paypal.com/cgi-bin/webscr', ['cmd'=>'_login-submit', 'login_email'=>$ARGV[0], 'login_password' => $passwd, 'submit.x'=>'Log In']); #getting another paypal cookie $cookie_jar->extract_cookies($response); $browser->cookie_jar ( $cookie_jar ); #moreover, this returns a redirection page $response->content =~ m{login_access=(\d+)}; $login_access = $1; #my $response = $browser->get("https://www.paypal.com/de/cgi-bin/webscr?cmd=_login-processing&login_cmd=_login-done&login_access=$login_access"); #login, part 3, follow the redirect my $response = $browser->get("https://www.paypal.com/de/cgi-bin/webscr?cmd=_login-done&login_access=$login_access"); $response->content =~ m{Business Account O.*?view}; print STDERR $&; print STDERR "\n"; #get history my $response = $browser->post ('https://www.paypal.com/de/cgi-bin/webscr', ['cmd'=>'_history-download-submit', 'history_cache'=>'', 'type'=>'custom_date_range', 'from_a'=>$from_a, 'from_b'=>$from_b, 'from_c'=>$from_c, 'to_a'=>$to_a, 'to_b'=>$to_b, 'to_c'=>$to_c, 'custom_file_type'=>'comma_allactivity', 'latest_completed_file_type'=>'', 'submit.x'=>'Download History', 'form_charset'=>'UTF-8']); print STDERR $response->content; print STDERR $from_a; print STDERR $from_b; print STDERR $from_c; print STDERR $to_a; print STDERR $to_b; print STDERR $to_c; print $response->content;