#!/usr/bin/perl #fcc redlight check # use strict; use warnings; use WWW::Mechanize; use MIME::Lite;#for emailing use Net::SSLeay; use Crypt::SSLeay; use Getopt::Std; use HTTP::Cookies; #use JavaScript::SpiderMonkey; #use WWW::Scripter; #use WWW::Scripter::Plugin::JavaScript; my $mech = new WWW::Mechanize(autocheck=>1); $mech->agent("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) Gecko/20050418 Firefox/1.0.3"); my $from = 'fromemail@whatever.com'; my $to = 'toemail@whatever.com'; my $cc = ''; my $subject = "RED LIGHT!!"; my $frn = "password"; my $pwd = "username"; my $url = "https://apps.fcc.gov/redlight/login.cfm"; my $message = "$frn appears to be in Red Light Status!\n\n$url"; my $path = "tmp"; my $filename = "test.html"; my $status = "STATUS: Green"; $mech->get( $url ); die sprintf(" crap(%d): %s ", $mech->status, $mech->content ) unless $mech->success; #$mech->submit_form( # form_name => 'login', # fields => { loginFrn=>$frn, password=>$pwd }, # fileds => { loginPassword=>$pwd }, # #button => 'submit', # ); $mech->submit_form( form_number => 1, with_fields => { loginFrn => $frn, loginPassword => $pwd, } ); #HOW THE FRIG DO YOU HIT THAT CONTINUE BUTTON?!? #$mech->click_button (value => "Continue"); #$mech->click( my $button [, 6, 28] ); #$mech->click_button (number=>1); #$mech->click_button (name => 'Continue'); #$mech->click_button (name => undef); #$mech->click( undef [, 6, 28] ); $mech->submit(); $mech->check_fields(); my $file = "/$path/$filename"; # create /tmp/test.html open(my $handle, ">", $file) || die "can't open $path: $!"; binmode($handle); # for raw; else set the encoding my $result = $mech->content; print $handle "$result\n"; close($handle) || die "can't close $path: $!"; #die; if ($mech->content =~ m/Invalid combination of/i) { print "login attempted, but failed\n"; die; } if ($mech->content =~ m/Red Light Display System Login/i) { print "Login not attempted?\n"; die; } die sprintf(" crap(%d): %s", $mech->status, $mech->content) unless $mech->success; if( $mech->content =~ m/delinquent/i ) { print "I win\n" } else { die "crap, didn't match green status. :-(\n"; }