| 1 | |||
| 2 | use strict; | ||
| 3 | |||
| 4 | package WWW::Scraper::Opcode::TR; | ||
| 5 | use base qw(WWW::Scraper::Opcode); | ||
| 6 | use vars qw($VERSION); | ||
| 7 | |||
| 8 | # new() Scraper::Opcode | ||
| 9 | # $cls - Op class | ||
| 10 | # $scaffold - current scaffold | ||
| 11 | # $params - ref to array of parames in the 'OP()' portion of the scaffold. | ||
| 12 | sub new { | ||
| 13 | my ($cls, $scaffold, $params) = @_; | ||
| 14 | my $self = bless {}; | ||
| 15 | my @scfld = @$scaffold; | ||
| 16 | shift @scfld; | ||
| 17 | my @fields; | ||
| 18 | map { push @fields, $_ unless !$_ || ref($_) || m{^#} } @scfld; | ||
| 19 | $self->{'fieldsCaptured'} = \@fields; | ||
| 20 | $self->{'fieldsDiscovered'} = ['name','content']; | ||
| 21 | return $self; | ||
| 22 | } | ||
| 23 | |||
| 24 | sub scrape { | ||
| 25 | my ($self, $scraper, $scaffold, $TidyXML, $hit) = @_; | ||
| 26 | |||
| 27 | my ($sub_string, $attributes) = $TidyXML->getMarkedTextAndAttributes('TR'); | ||
| 28 | return undef unless defined($sub_string); | ||
| 29 | |||
| 30 | my @ary = @$scaffold; | ||
| 31 | shift @ary; | ||
| 32 | my $fldnam = shift @ary; | ||
| 33 | if ( $fldnam && (ref($fldnam) ne 'ARRAY') ) { | ||
| 34 | $hit->plug_elem($fldnam, ${$TidyXML->asString()}, $TidyXML); | ||
| 35 | } | ||
| 36 | |||
| 37 | return ($self->_next_scaffold($scaffold), $sub_string, $attributes); | ||
| 38 | } | ||
| 39 | |||
| 40 | |||
| 41 | 1; |