jdlev has asked for the wisdom of the Perl Monks concerning the following question:
Hello perl gurus...I've been struggling with reformatting the output of data in HTML::TableExtractor. Here is ultimately what I want to do: 1) Go to website 2) Scrape table on website based on their location on the page, because there are no freakin headers! 3) Pull the information gathered into a mysql database
So far, here is what I've gotten:
use lib qw( ..);
use HTML::TableExtract;
use LWP::Simple;
use Data::Dumper;
my $te = new HTML::TableExtract( depth=>3, count=>0, gridmap=>0);
my $content =
get("http://www.servpro.com/locator/lookup.asp?stname=Alabama&state=AL");
$te->parse($content);
foreach $ts ($te->table_states)
{
foreach $row ($ts->rows)
{
print Dumper $row;
# print Dumper $row if (scalar(@$row) == 2);
}
}
If you save the above, and run it from your cmd prompt, it creates a very messy return, but hey, at least its something right! What I want to do is structure the data into an array so I can send the information to a mysql database.
I have no idea how to get HTML::TableExtractor to bring in an orderly fashion. I've tried to see what it is returning by simply printing one of the variables (like $row rather than using the DUMPER function) HTML::TableExtractor is tabulating, and it comes back by printing something like: "ARRAY(0x1b3243f)ARRAY(0x1b3432)"
First off, what are the strange things it is returning? I've never used dumper, but don't really like it. I would prefer to set a new string equal to each variable in the array. Then send that information to mysql.
One other quick question, can anyone tell me in plain english what
"foreach $ts ($te->table_states)" is telling the computer program to do?
Any help is greatly appreciated...hope everyone has a good weekend! :)
I need to go meditate after working on this stupid thing all day! OOOOOOOOOOOOOOOMMMMMMMMMMMMMMMMMMMMM
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: PERL HTML::TableExtractor
by Limbic~Region (Chancellor) on Dec 20, 2008 at 02:08 UTC | |
|
Re: PERL HTML::TableExtractor
by wfsp (Abbot) on Dec 20, 2008 at 07:37 UTC | |
by jdlev (Scribe) on Dec 22, 2008 at 18:09 UTC | |
by wfsp (Abbot) on Dec 23, 2008 at 06:56 UTC | |
|
Re: PERL HTML::TableExtractor
by jethro (Monsignor) on Dec 20, 2008 at 05:21 UTC |