#!/usr/local/bin/perl require 5.002; use LWP; use LWP::UserAgent; use HTTP::Request::Common qw(POST); my $errors = 0; my $error_string = ""; my ($sec,$min,$hr,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); my $y = $year; $year = $year + 1900; $mon = $mon + 1; if ($mday < 10) { $mday = '0' . $mday; } if ($mon < 10) { $mon = '0' . $mon; } # Get the Pennyweb Standard my $cents1 = 0; my $content =""; my $contentstr = 'account_number=2116A2025&password=glamazon&from_month='. $mon . '&from_day=' . $mday . '&from_year=' . $year; $contentstr = $contentstr . '&to_month='. $mon . '&to_day=' . $mday . '&to_year=' . $year; $url = 'http://reports.pennyweb.com/shellpenny-cgi/hostreports.pl'; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new('POST',"$url"); $req->content_type ('application/x-www-form-urlencoded'); $req->content ($contentstr); my $obj = $ua->request($req); if ($obj->is_success()) { $content = $obj->as_string; $_ = $content; @monies = m/(\$\d+\.\d+)/sg; $_ = $monies[0]; s/\$//; $cents1 = sprintf("%.2f",$_); $cents1 = $cents1 * 100; } else { $errors = $errors + 1; $error_string = "Error getting from PennyWeb Standard: " . $obj->message ."
"; } # Get the Pennyweb Standard my $circusme = 0; $content =""; $contentstr = 'account_number=2250A1026&password=glamazon&from_month='. $mon . '&from_day=' . $mday . '&from_year=' . $year; $contentstr = $contentstr . '&to_month='. $mon . '&to_day=' . $mday . '&to_year=' . $year; $url = 'http://reports.pennyweb.com/shellpenny-cgi/hostreports.pl'; $ua = LWP::UserAgent->new; $req = HTTP::Request->new('POST',"$url"); $req->content_type ('application/x-www-form-urlencoded'); $req->content ($contentstr); $obj = $ua->request($req); if ($obj->is_success()) { $content = $obj->as_string; $_ = $content; @monies = m/(\$\d+\.\d+)/sg; $_ = $monies[0]; s/\$//; $circusme = sprintf("%.2f",$_); $circusme = $circusme * 100; } else { $errors = $errors + 1; $error_string = "Error getting from PennyWeb CircusMe: " . $obj->message ."
"; } #Get the Pennyweb Premium my $cents2 = 0; $contentstr = 'hostID=F2HT1869840&password=glamazon&s_month='. $mon . '&s_day=' . $mday . '&s_year=' . $year; $url = 'http://reports.pennyweb.com/shellpenny-cgi/hostID_reports.pl'; $req = HTTP::Request->new('POST',"$url"); $req->content_type ('application/x-www-form-urlencoded'); $req->content ($contentstr); $obj = $ua->request($req); if ($obj->is_success()) { $content = $obj->as_string; $_ = $content; @monies = m/>(\$*\d+\.*\d+)/sg; @monies = reverse @monies; #count from the end $_ = $monies[0]; s/\$//; $cents2 = sprintf("%.2f",$_); $cents2 = $cents2 * 100; } else { $errors = $errors + 1; $error_string = $error_string . "Error getting from PennyWeb Premium: " . $obj->message ."
"; } #Get the AllClicks my $cents3 = 0; $url = 'http://www.allclicks.com/cgi-bin/stat.cgi'; my $e = 0; #some date adjustments my $m = $mon - 1; if ($mday < 16) { $e = 0; } else { $e = 1; } $contentstr = 'l=altheweb&p=glamazon&y=' . $y . '&m=' . $m . '&s=100&e=' . $e; $url = $url . '?' . $contentstr; $req = HTTP::Request->new('GET',"$url"); $obj = $ua->request($req); if ($obj->is_success()) { $content = $obj->as_string; $_ = $content; @monies = m/(\$\s*\d+\.\d+)/sg; #put all dollar amounts into an array @monies = reverse @monies; #count from the end $_ = $monies[3]; s/\$\s*//; $cents3 = sprintf("%.2f",$_); $cents3 = $cents3 * 100; } else { #what if request fails? $errors = $errors + 1; $error_string = $error_string . "Error getting from AllClicks: " . $obj->message ."
"; } my $total = ($cents1 + $cents2 + $cents3 +$circusme)/100; my $total_formatted = sprintf("%.2f",$total); print "Content-type: text/html\n\n"; print "Gore-O-Meter"; print "\n"; print "\n\n"; print "\n"; print "today's total: \$$total_formatted

"; print "penny search: $cents1
"; print "penny circusme: $circusme
"; print "penny premium: $cents2
"; print "allclicks: $cents3
"; if ($errors) { print "$error_string"; }; print "
"; #http://www.google.com/search?q=cache:38771586&dq=cache:www.activestate.com/ActivePerl/docs/lib/site/lwpcook.html #Documents protected by basic authorization can easily be accessed like this: #use LWP::UserAgent; #$ua = new LWP::UserAgent; #$req = new HTTP::Request GET => 'http://www.sn.no/secret/'; #$req->authorization_basic('aas', 'mypassword'); #print $ua->request($req)->as_string;