in reply to HTML::TableExtract - ugly - is there better way?
It would take a little work to put the "$" back in front of the "Last Sale*" amount, but this should get you started.use strict; use warnings; use HTML::TableExtract; #Get HTML file and set up headers for HTML::TableExtract my $doc = 'nasdaq-stocks.txt'; my $html = do{ local $/=undef; open my $f,"<", $doc or die $!;<$f>}; my $headers = ['Symbol', 'Last Sale*', 'Change Net / %', 'Share Volume +']; #table 4 is advances. Need to do again for 5 decliners my $table_extract = HTML::TableExtract->new(count => 4, headers => $he +aders); $table_extract->parse($html); print join (" \t",@$headers),"\n"; for my $r ($table_extract->rows()){ my @cols = map {/([\w\.]+)\W+([\w\.\%]*)/} @$r; print join ("\t",@cols), "\n"; }
...it is unhealthy to remain near things that are in the process of blowing up. man page for WARP, by Larry Wall
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HTML::TableExtract - ugly - is there better way?
by rtwolfe (Initiate) on Apr 10, 2017 at 03:31 UTC | |
by NetWallah (Canon) on Apr 10, 2017 at 03:39 UTC |