in reply to Re: Fetching a table data in a HMTL file
in thread Fetching a table data in a HMTL file

I prefer to use HTML::TreeBuilder. For example, this code will pull out the table on the PerlMonks home page that lists the currently logged in users:

use 5.010; use warnings; use strict; use HTML::TreeBuilder; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $fetch_result = $ua->get("http://www.perlmonks.org"); my $tree = HTML::TreeBuilder->new_from_content($fetch_result->content) +; my $nodelet_table = $tree->look_down( '_tag' => 'table', 'id'=>'nodele +t_container' ); my $other_users_cell = $nodelet_table->look_down('id'=>'Other_Users'); my @other_users_list = $other_users_cell->look_down('_tag'=>'li'); print "User logged into PerlMonks:\n"; foreach my $user_element ( @other_users_list ) { print "\t".$user_element->as_text."\n"; }

Replies are listed 'Best First'.
Re^3: Fetching a table data in a HMTL file
by Cicatrix (Novice) on Mar 23, 2011 at 04:37 UTC
    thanks chrestomanci !!! i'm feeling lucky :)