#!/usr/bin/perl my $vzwuser = "LOGINHERE"; my $vzwpass = "PASSHERE"; my $tmpfile = "/tmp/vzw.$$"; my $usagefile = "/tmp/vzwusage.$$"; my $quiet = ""; # change this to -q to turn off wget output package IdentityParse; use base "HTML::Parser"; my $cookie1; my $cookie2; my $pf = 0; my $wf = 0; my $wn = ""; my $msg = ""; # main start system "wget https://myaccount.verizonwireless.com/vzs/login $quiet --post-data \"j_username=$vzwuser\&j_password=$vzwpass\" -O $tmpfile --save-headers"; open IN, $tmpfile or die "can't open $tmpfile\n"; while () { $line = $_; chomp $line; if ($line =~ /JSESSIONID=/) { @spl = split / /, $line; $cookie1 = $spl[1]; } if ($line =~ /vzw.context=/) { @spl = split / /, $line; $cookie2 = $spl[1]; } } unless ($cookie1 and $cookie2) { die "can't get cookies\n"; } #print "cookie1 $cookie1\n"; #print "cookie1 $cookie2\n"; print "wget https://wbillpay.verizonwireless.com/vzw/overview/unbilled-usage-minutes.do --cookies=off --header \"Cookie: $cookie1\" --header \"Cookie: $cookie2\" -O $usagefile"; system "wget https://wbillpay.verizonwireless.com/vzw/overview/unbilled-usage-minutes.do --cookies=off --header \"Cookie: $cookie1\" --header \"Cookie: $cookie2\" -O $usagefile"; my $p = new IdentityParse; $p->parse_file("$usagefile"); sub text { my ($self, $text) = @_; if ($text =~ /^[\s]*$/) { return; } #print "text $text\n"; if ($pf) { $text =~ s/[\D]//g; if ($wn) { $msg .= "Wireless usage for $wn is $text\n"; } else { $msg .= "error getting usage for wireless no $wn\n"; } #print "PEAK FOUND: $text\n"; $pf = 0; $wn = ""; } if ($wf) { #print "WIRELESS FOUND: $text\n"; $wf = 0; $wn = "$text"; } if ($text =~ /^Peak Minutes/i) { #print "PEAK MINUTES FOUND\n"; $pf++; } if ($text =~ /^Wireless No/i) { #print "WIRELESS NO FOUND\n"; $wf++; } } #unlink $tmpfile; #unlink $usagefile; print "msg is $msg";