Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Help With Online Table Scraper

by GrandFather (Cardinal)
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("http://finance.yahoo.com/q/ks?s=MNDO+Key+Statistics") +; 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"; }

Prints:

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


Comment on Re: Help With Online Table Scraper
Select or Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://890904]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-08-22 01:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (145 votes), past polls