0

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:test123@abc.com: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"

cjm
  • 61,471
  • 9
  • 126
  • 175
Cindrella
  • 1,671
  • 7
  • 27
  • 47
  • Is the package HTML::TreeBuilder installed? – jpstrube Sep 27 '12 at 11:12
  • @Jan Strube : Yes it is installed. Executed the file successfully using new_from_file() which is in my local system. – Cindrella Sep 27 '12 at 11:19
  • Do you have the latest version of HTML::TreeBuilder and is LWP::UserAgent installed? – jpstrube Sep 27 '12 at 11:27
  • @Jan Strube: Installed version of HTML::TreeBuilder is "3.13". LWP::UserAgent is 2.033 – Cindrella Sep 27 '12 at 11:37
  • 1
    Looks like new_from_url was added in 5.00 - http://cpansearch.perl.org/src/CJM/HTML-Tree-5.02/Changes – RobEarl Sep 27 '12 at 11:52
  • 1
    Try to update. The latest version of HTML::TreeBuilder is 5.03. – jpstrube Sep 27 '12 at 11:53
  • Tried to install the latest version but getting error:make test had returned bad status, won't install without force – Cindrella Sep 27 '12 at 12:00
  • @Jan Strube : Tried to install the latest version but getting error:make test had returned bad status, won't install without force – Cindrella Sep 27 '12 at 12:17
  • @Mohini, I'm the current co-maintainer of HTML-Tree. I haven't gotten any reports of test failures with 5.03. Please [send a bug report](https://rt.cpan.org/Ticket/Create.html?Queue=HTML-Tree) with the complete output of trying to install HTML-Tree and the output of "perl -V". – cjm Sep 27 '12 at 16:25
  • @cjm: will sure send the report – Cindrella Sep 28 '12 at 04:25
  • @cjm: Just now tried to send a bug report. but its asking for login.Don't have login :-). Please let me know any other way to send the bug report. – Cindrella Sep 28 '12 at 04:36
  • You can get a [Bitcard account](https://www.bitcard.org/) just by filling in [the form](https://www.bitcard.org/register?bc=%3D%3A%3Ap%3Dbc), but you can also send email to bug-html-tree at rt dot cpan org without opening an account. – cjm Sep 28 '12 at 06:08
  • @cjm created the bug https://rt.cpan.org/Public/Bug/Display.html?id=79900 – Cindrella Sep 28 '12 at 06:58

1 Answers1

1

First check the latest version of the module HTML::TreeBuilder. Try to install it from cpan.

cpan -i HTML::TreeBuilder

Mandar Pande
  • 12,250
  • 16
  • 45
  • 72
  • installed from cpan only. cpan is extracting the files from the latest version of the HTML::TreeBuilder only . But it is not getting succeffuly installed – Cindrella Sep 27 '12 at 12:19
  • "But it is not getting succeffuly installed" ? What error it gives ? – Mandar Pande Sep 27 '12 at 12:22
  • error:make test had returned bad status, won't install without force . Even tried force make install command.It is getting installed. But installed version is still showing the 3.13 version – Cindrella Sep 27 '12 at 12:24
  • These liens should not be the main issues ? Just read entire cpan log and check for any other error. AND Try to install it again and check where it shows: this modules is up to date ? – Mandar Pande Sep 27 '12 at 12:27
  • Try it again by reinstalling it and check whethere it shows correct/required version with UP TO DATE remark. – Mandar Pande Sep 28 '12 at 05:47
  • Tried reinstallation. Sometimes it shows installation is success but when checked isntallation version ,it shows the old one only – Cindrella Sep 28 '12 at 05:50
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/17278/discussion-between-mandy-and-mohini) – Mandar Pande Sep 28 '12 at 05:57