In the event of this random column changing you definitely need HTML::TreeBuilder. Straight-up string parsing will result in disaster - HTML::TreeBuilder, well, makes a proper tree structure out of the resulting HTML. Just pass in the content with $mech->content, have it parse, and follow the methods in HTML::Element. The one you want for tree traversal is look_down. The generalized way to go down the nodes is:
Hope this helps.my @table = $root->look_down( _tag => 'table', .... ); # <== insert ad +ditional attributes to specify the proper table while ( @table ) { my $node = shift @table; if ( ref $node ) { .... # possibly do stuff depending on $node->tag and $node->attr( +...) unshift @table, $node->content_list; } else { .... # here we have the leaf, or plain text } }
In reply to Re: www::mechanize to scrape randomly ordered data?
by whakka
in thread www::mechanize to scrape randomly ordered data?
by punch_card_don
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |