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

Hi Monks,

I am using html table extract to fetch the data as below...

Can you please help to get the rows which are in red background...?

use strict; use LWP::UserAgent; use HTTP::Request; use HTML::TableExtract; my $ua = LWP::UserAgent->new(timeout => 10); my $url = 'http://sdasd.com'; my $request = HTTP::Request->new('GET',$url); my $response = $ua->request($request); if ($response->is_success){ my $te = HTML::TableExtract->new ( headers => [ 'USER NAME','Trans +']); $te->parse($response->content); foreach my $ts ($te->table_states) { foreach my $row ($ts->rows) { if ($row !~ "disabled"){ print @$row; } } } }

GrandFather moved commentary outside code block

Replies are listed 'Best First'.
Re: Fetch the data with red background...
by ww (Archbishop) on Jul 09, 2009 at 10:31 UTC

    We'll need a bit more information (and not in the form of the address of an unknown site buried in the code).

    How would we know which rows have red backgrounds?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:/ +/www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Some red rows</title> <style type="text/css"> .red { color:black; background-color:red; } .b { font-weight:bold; } </style> </head> <body> <table> <tr><td>foo</td></tr> <tr bgcolor="red"><td>bar with bgcolor in the row tag (deprecated)</td +></tr> <tr><td class="b">no color but bold</td></tr> <tr class="red"><td>qux with css in the tr</td></tr> <tr bgcolor="#FF0000"><td>qum on red background</td></tr> </table> </body> </html>

    produces (rows 3 and 4 (corrected row numbers) do not render here as coded because of restrictions within the Monastery):

    foo
    bar with bgcolor in the row tag (deprecated)
    no color but bold
    qux with css in the tr
    qum on red background

    And these are just a couple of the ways to use "red" as the background color of a row.