SteinerKD has asked for the wisdom of the Perl Monks concerning the following question:
As some might know I'm working on a script to collect gaming stats for squad members from a website. Now I'm getting close to a working thing (Much thanks to wfsp).
What I'm working on now is adapting a sub that wfsp wrote to collect data from specific spots on a webpage by feeding the sub coordinates my $databit = collect_data(x, y, z); basically.
Guess I'm getting tired and can't see the wood for all the trees now, but I just can't figure out the treebuilder function for my use (found a message here about it but all links were dead).
The code I'm adapting:
sub collect_data { my ($tab, $row, $cell) = @_; # we want table X my @tables = $t->look_down(_tag => q{table}); my $table = $tables[$tab]; # Xth row my @trs = $table->look_down(_tag => q{tr}); my $tr = $trs[$row]; # Xth column my @tds = $tr->look_down(_tag => q{td}); my $td = $tds[$cell]; # get any text my $data = $td->as_text; return $data; }
The original sub was to test if a new page existed and was feed a page number ($t) and it returned a new one if it existed. I however feed it the 3 positional variables and expect the data at that location to be feed back.
As you can see the $t is still in there as I'm unsure what the line should be without it. I've also inserted the supplies coordinates where I believe they should go to work as intended.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using HTML::TreeBuilder to collect data for populating variables
by wfsp (Abbot) on Aug 04, 2010 at 07:20 UTC | |
|
Re: using HTML::TreeBuilder to collect data for populating variables
by aquarium (Curate) on Aug 04, 2010 at 01:10 UTC | |
by wfsp (Abbot) on Aug 04, 2010 at 06:55 UTC | |
by GrandFather (Saint) on Aug 04, 2010 at 10:21 UTC | |
by SteinerKD (Acolyte) on Aug 04, 2010 at 01:22 UTC |