Hi
I am extracting some data from my project webpage and dumping them in a excel sheet. The webpage has got a table on it showing some results and status of few job runs. It uses green to denote a 'pass' and red to denote a 'fail' like below :

<TD><FONT COLOR = "green">PASS</FONT></TD> <TD><FONT COLOR = "red">FAIL</FONT></TD>

I am able to successfully dump the content of the page in a excel sheet but not the colors of the table cells. How can I restore the colors as well when dumping the content in excel?
Below is my code

use Spreadsheet::WriteExcel; use HTML::TableExtract; require LWP::UserAgent; my $ua = new LWP::UserAgent(); my $request = HTTP::Request->new(GET=>"http://autoreport.nextgen.com") +; my $response ; $response = $ua->request($request); $response = $response->content(); # Create a new Excel file my $filename = "/home/user/result.xls"; my $workbook = Spreadsheet::WriteExcel->new($filename); # Add a worksheet my $worksheet = $workbook->add_worksheet('exec2'); # Define the format and add it to the worksheet my $format = $workbook->add_format( center_across => 1, bold => 1, size => 10, border => 4, color => 'black', bg_color => 'cyan', border_color => 'black', align => 'vcenter', ); my $te = HTML::TableExtract->new( keep_html => 0); $te->parse($response); foreach my $ts ($te->tables) { my $nrow=0; foreach my $row ($ts->rows) { my $ncol=0; foreach my $col (@$row) { $worksheet->write($nrow,$ncol++,$col) if defined $col; } $nrow++; } $nrow++; }

Thanks


In reply to How to restore the colors of a webpage when extracting data by ghosh123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.