Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Extract HTML Table rows

by bobf (Monsignor)
on Dec 23, 2009 at 14:44 UTC ( #814104=note: print w/ replies, xml ) Need Help??


in reply to Extract HTML Table rows

I have found HTML::TableExtract to be easy to use in simple cases:

use strict; use warnings; use HTML::TableExtract; my $content; { local $/ = undef; # slurp mode $content = <DATA>; } my $te = HTML::TableExtract->new(); $te->parse( $content ); foreach my $ts ( $te->tables() ) { foreach my $row ( $ts->rows() ) { print join ( "\t", @$row ), "\n"; } } __DATA__ <html><head><title>Person Profile</title></head> <center> <font size=5><b>Profile</b></font> <table cellspacing="1" cellpadding="1"> <tr> <td class="rlab">Short Name:</td> <td class="l">John</td> </tr> <tr> <td class="rlab">Long Name:</td> <td class="l">John Abraham</td> </tr> <tr> <td class="rlab">Company:</td> <td class="l">Idea</a></td> </tr> </tr> <tr> <td class="rlab">Currency:</td> <td class="l">EUR</td> </tr> </table> </body></html>


Comment on Re: Extract HTML Table rows
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://814104]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2015-07-04 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls