Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

After userid and password authentication , i am getting a page containing some data. Inside the fom tag, there is a table conatining 5 columns. I would like to get 1st,3rd and 5th column data and display it. I don't want to display other details (means, the data in the above part (images) and below part (Back to home link). html code as....

<html> <head> <title>Account Generated</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <table border="0" width="110%" bgcolor="#000000" cellspacing="0" cellp +adding="0"> <tr> <td width="100%"> <a href="logout.asp"><img src=".\images\blog.jpg" alt="Log Out of +Web Administration" border="0" WIDTH="72" HEIGHT="32"></a><a href="m_ +account.asp"><img src=".\images\baccount.jpg" alt="Add, Edit, Delete, + Enable and Disable Accounts" border="0" WIDTH="90" HEIGHT="32"></a> +<a href="m_report.asp"><img src=".\images\breport.jpg" alt="Generate +Bills, Call Summary and Traffic Reports" border="0" WIDTH="72" HEIGHT +="32"></a><img src=".\images\_bmaint.jpg" alt="bmaint.jpg (7032 bytes +)" border="0" WIDTH="90" HEIGHT="32"> </td> </tr> </table>
<form method="POST" action="abc.pl"> <p><font face="Arial Narrow"><strong>View By&nbsp; </strong><input t +ype="radio" value="Date" name="SortOrder" checked>Date&nbsp;&nbsp;&nbsp;&nbsp; < +input type="radio" value="Amount" name="SortOrder" >Amount &nbsp;&nbsp;&nbsp; <input type="submit" value="View" name="FormButto +n" style="font-family: MS Sans Serif">&nbsp; <input type="reset" value= +"Reset" name="FormButton" style="font-family: MS Sans Serif"></font></p> </form> <font face="Arial Narrow"> <p><strong> </p> <small> <font face="Arial Narrow"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="84" bgcolor="#000000"><font face="Arial Narrow" color=" +#FFFFFF"><strong>Account </strong></font></td> </font><td width="65" bgcolor="#000000"><font face="Arial Narrow" +color="#FFFFFF"><strong>Date</strong></font></td> <td width="107" bgcolor="#000000"><strong><font face="Arial Narrow +" color="#FFFFFF">Description</font></strong></td> <td width="55" bgcolor="#000000"><font face="Arial Narrow" color=" +#FFFFFF"><strong>Qty.</strong></font></td> <td width="86" bgcolor="#000000"><font face="Arial Narrow" color=" +#FFFFFF"><strong>Amount</strong></font></td> </tr> </small> <tr> <td width="84" bgcolor="#C0C0C0"><small><small>12345</small></sma +ll> </td> <small> <td width="65" bgcolor="#C0C0C0"><small><font face="Arial Narrow" +>7/1/03</font></small> </td> <td width="107" bgcolor="#C0C0C0"><font face="Arial Narrow"><smal +l>FROM 1001</small></font></small></td> <small> <td width="55" bgcolor="#C0C0C0"><small><font face="Arial Narrow" +>10.00</font></small> </td> <td width="86" bgcolor="#C0C0C0"><small><font face="Arial Narrow" +>$1.00</font></small> </td> </tr> </small> <tr> <td width="84" ><small><small>12345</small></small> </td> <small> <td width="65" ><small><font face="Arial Narrow">7/2/03</font></sm +all> </td> <td width="107" ><font face="Arial Narrow"><small>FROM 1001</small +> </font></small></td> <small> <td width="55" ><small><font face="Arial Narrow">3.00</font></smal +l> </td> <td width="86" ><small><font face="Arial Narrow">$0.30</font></sma +ll> </td> </tr> </small> <tr> <td width="84" bgcolor="#C0C0C0"><small><small>12345</small></sma +ll> </td> <small> <td width="65" bgcolor="#C0C0C0"><small><font face="Arial Narrow" +>7/2/03</font></small> </td> <td width="107" bgcolor="#C0C0C0"><font face="Arial Narrow"><smal +l>FROM 1001</small> </font></small></td> <small> <td width="55" bgcolor="#C0C0C0"><small><font face="Arial Narrow" +>3.00</font></small> </td> <td width="86" bgcolor="#C0C0C0"><small><font face="Arial Narrow" +>$0.30</font></small> </td> </tr> </small> <tr> <td width="84" ><small><small>12345</small></small> </td> <small> <td width="65" ><small><font face="Arial Narrow">7/2/03</font></sm +all> </td> <td width="107" ><font face="Arial Narrow"><small>FROM 1001</small +> </font></small></td> <small> <td width="55" ><small><font face="Arial Narrow">1.00</font></smal +l> </td> <td width="86" ><small><font face="Arial Narrow">$0.10</font></sma +ll> </td> </tr> </small> <tr> <td width="84" bgcolor="#C0C0C0"><small><small>12345</small></sma +ll> </td> <small> <td width="65" bgcolor="#C0C0C0"><small><font face="Arial Narrow" +>7/2/03</font></small> </td> <td width="107" bgcolor="#C0C0C0"><font face="Arial Narrow"><smal +l>FROM 1001</small> </font></small></td> <small> <td width="55" bgcolor="#C0C0C0"><small><font face="Arial Narrow" +>1.00</font></small> </td> <td width="86" bgcolor="#C0C0C0"><small><font face="Arial Narrow" +>$0.10</font></small> </td> </tr> <tr> <td width="84" ><strong><font face="Arial Narrow" color="#000000"> +<small>&nbsp;</small> </font></strong></td> <td width="65" ><strong><font face="Arial Narrow" color="#000000"> +<small>&nbsp;</small> </font></strong></td> <td width="107" <font face="Arial Narrow"><strong><font face="Arial Narrow" color="#000000"><small>Credits: 0</small> </fo +nt></strong></td> <td width="55" ></td> <td width="86" ><strong><font face="Arial Narrow" color="#000000"> +<small>$0.00</small> </font></strong></td> </tr> </table> <p align="center"><a href="test.pl"><small><font face="Arial Narrow">B +ack to Home</font></small></a></p> </body> </html>
How can i get it?
Thanks..

update (broquaint): added formatting + <readmore> tag

Replies are listed 'Best First'.
Re: How can we re-arrange the table content?
by Corion (Patriarch) on Jul 07, 2003 at 11:38 UTC

    Take a look at mojotoads module HTML::TableExtract, which is well-suited for extracting data out of HTML tables into arrays.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
      Corion
      Thanks a lot.