Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Help With Online Table Scraper

by GrandFather (Sage)
on Mar 02, 2011 at 04:59 UTC ( #890904=note: print w/replies, xml ) Need Help??

in reply to Help With Online Table Scraper

You've got the basic bits, but you've put them together the wrong way and there's a lot of stuff missing. Here's a starting point:

use strict; use warnings; use LWP::Simple; use HTML::TableExtract; my $money = get("") +; my $p = new HTML::TableExtract(); $p->parse($money); my $table = $p->table(2, 0); for my $row ($table->rows ()) { ! defined and $_ = ' ' for @$row; print "@$row\n"; }


Market Cap (intraday)5: 57.14M Enterprise Value (Mar 2, 2011)3: 39.06M Trailing P/E (ttm, intraday): 11.88 Forward P/E (fye Dec 31, 2012)1: N/A PEG Ratio (5 yr expected)1: N/A Price/Sales (ttm): 2.91 Price/Book (mrq): 2.41 Enterprise Value/Revenue (ttm)3: 1.96 Enterprise Value/EBITDA (ttm)3: 5.95
True laziness is hard work

Replies are listed 'Best First'.
Re^2: Help With Online Table Scraper
by Anonymous Monk on Mar 02, 2011 at 05:27 UTC
    ! defined and $_ = ' ' for @$row;
    You maybe mean ! defined and  $_ != ' ' for @$row;   ?

      No. That wouldn't make any sense at all!

      Perhaps I should have gone with my second instinct and written that line as:

      for my $cell (@$row) { if (! defined $cell) { $cell = ' '; } }

      I didn't because the fairly trivial task of setting undefined cells to a space becomes the dominant code in the sample. I'd hoped that the line would be pretty much ignored, but in retrospect that was pretty silly really.

      True laziness is hard work

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://890904]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2018-05-26 18:21 GMT
Find Nodes?
    Voting Booth?