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

I'm writing a little program for my father, (as a gift) he's a bit of a stock market addict who spends all day futzing around on the computer looking up stock prices and all that.

i told him to try generating an "online portfolio" and get all of that automated so he dosen't have to waste so much time on the lookups and can spend more time on his research/analysis. His response was that he did not want his information in somone else's database (understandable i geuss)

i've decided to write a little number that parses through a list of his favorite ticker symbols and sends a GET to the server, parses the incoming HTML and saves all of the day's info to a file (which he can edit in XL)

my problem is parsing the info out of a table and into a comma delimited line of printout text
print "$symbol,$value,$volume... etc"
i've tried using HTML::FormatText but that just leaves me with "table not shown"

i know someone here is smarter than me and can give me this little boost :)

Replies are listed 'Best First'.
Re: Extracting Data from an HTML table
by dkubb (Deacon) on Jan 15, 2001 at 13:57 UTC

    One module you will want to check out is HTML::TableExtract

    It allows parsing of HTML tables, even nested ones, which can be rather complicated to roll on your own.

Re: Extracting Data from an HTML table
by danger (Priest) on Jan 15, 2001 at 14:12 UTC

    Others have pointed you to methods of extracting table data, but you might be interested to know that some web stock services allow grabbing data in CSV format already -- yahoo's stock pages do so, and the Finance::YahooQuote module might be something you want to look at.

Re: Extracting Data from an HTML table
by davorg (Chancellor) on Jan 15, 2001 at 13:55 UTC

    For parsing HTML, you really should be using HTML::Parser or one of its subclasses. Sounds to me like HTML::Tokeparser or HTML::TreeBuilder would be most useful for you in this case.

    Update: Or maybe HTML::TableExtract, which I hadn't heard of until I saw it mentioned in this thread :)

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Re: Extracting Data from an HTML table
by t0mas (Priest) on Jan 15, 2001 at 13:57 UTC
      merci beaucoup :)
Re: Extracting Data from an HTML table
by andye (Curate) on Jan 15, 2001 at 17:21 UTC
    You could just fetch the page using Lynx. Inelegant I know, but easy.

    andy.