Reputation: 1721
Using HTML::TreeBuilder->new_from_url() want to go to a website say https://abc.com/index.html and want to display some values from that html page.
https://abc.com/index.html asks for user authentication(test/test123 are username and password). I have used below code: File name: finaldisplay.pl
#!/usr/bin/perl
use HTML::TreeBuilder;
use HTML::Entities;
my $url = "http://test:[email protected]:8080/index.html";
my $tree = HTML::TreeBuilder->new_from_url($url);
$tree->elementify;
for my $post( $tree->look_down( _tag => q{tr}, 'class' => 'row-odd' ) ) {
my $disk_value;
my $name = $post->look_down( _tag => q{td}, 'class' => 'stats_left');
my $data = $name->as_trimmed_text;
if($data =~ /Home Directory/){
$disk_value = $post->look_down( _tag => q{td}, 'class' => 'stats_right' )->as_trimmed_text;
print STDERR "$data : $disk_value\n";
}
elsif($data =~ /Disk Space Usage/){
$disk_value = $post->look_down( _tag => q{td}, 'class' => 'stats_right' );
$disk_value = ($disk_value->content_list)[0];
$disk_value = encode_entities($disk_value);
print STDERR "$data : $disk_value\n";
}
}
for my $post( $tree->look_down( _tag => q{tr}, 'class' => 'row-even' ) ) {
my ($disk_value, $disk);
my $name = $post->look_down( _tag => q{td}, 'class' => 'stats_left');
my $data = $name->as_trimmed_text;
if($data =~ /Main Domain/){
$disk = $post->look_down( _tag => q{td}, 'class' => 'stats_right' );
$disk_value = $post->look_down( _tag => q{b})->as_trimmed_text;
print STDERR "$data : $disk_value\n";
}
}
When I am running the file from command line getting error "Can't locate auto/HTML/TreeBuilder/new_from_ur.al in @INC (@INC contains: C:/Per l/lib C:/Perl/site/lib .) at finaldisplay.pl line 8"
Upvotes: 0
Views: 671
Reputation: 12984
First check the latest version of the module HTML::TreeBuilder
.
Try to install it from cpan
.
cpan -i HTML::TreeBuilder
Upvotes: 1