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.


In reply to using HTML::TreeBuilder to collect data for populating variables by SteinerKD

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.