Fellow Monks
I am writing a script that will query a url and get the html code from the page and then parse it with HTML::TableExtract. I am getting and error in my log file that says:
HTML::TableExtract=HASH(0x1df15b8)
Does anyone know how i can fix this or maybe show me a better way to get my information. The information i need is in a table on this page.
Here's a copy of my code. Please, any help would be appreciated. THNX.
Ray
# Ray Espinoza
# GetAPC.pl
# This script will take a list of ip addresses of APCs and
# send the desired output to a textfile.
######################################################################
#!D:\perl\bin -w
use LWP::UserAgent;
use HTTP::Request;
use HTML::TableExtract
####################################################################
+#
# Asking for Output file names.
####################################################################
+#
print "Enter the name of the output file:\n";
chomp($OutFile = <STDIN>);
####################################################################
+##
# Opens the outfile for appending
####################################################################
+##
open(OUT,">$OutFile") || die "Can't create $OutFile: $!";
####################################################################
+##
# This will log into the apc and grab the html and stuff it into an
# array and then i will take that array and add a new line to every
# line and stuff that into a variable
####################################################################
+###
$ua = new LWP::UserAgent;
$url = 'http://192.168.1.1/pdumaina';
#print $url;
$request = new HTTP::Request('GET',$url);
$request->authorization_basic('login', 'password');
$ua->timeout(10);
$response = $ua->request($request);
$responsecode = $response->code();
if ($responsecode != 200) {
print "Failed Request: $responsecode\n";
} else {
# login successful, let's get the html code into a variable
@ARRAY_OF_LINES = (split "\n", $ua->request($request)->as_stri
+ng);
foreach $line (@ARRAY_OF_LINES) {
$html_code .= $line . "\n";
}
}
####################################################################
+####
# This will attempt to use HTML::TableExtract to look for these spec
+ific
# headers in the html tables and print out the values in the table.
####################################################################
+####
$te = new HTML::TableExtract( headers => [qw(Outlet Device Name)] );
$te->parse($html_code);
print OUT $te;
close(OUT) || warn "Couldn't close $OutFile";