| 1 | |||
| 2 | use strict; | ||
| 3 | |||
| 4 | package WWW::Scraper::Opcode::TABLE; | ||
| 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 | $self->{'fieldsDiscovered'} = ['name','content']; | ||
| 16 | return $self; | ||
| 17 | } | ||
| 18 | |||
| 19 | sub scrape { | ||
| 20 | my ($self, $scraper, $scaffold, $TidyXML, $hit) = @_; | ||
| 21 | my $next_scaffold; | ||
| 22 | |||
| 23 | my ($sub_string, $attributes) = $TidyXML->getMarkedTextAndAttributes('TABLE'); | ||
| 24 | return undef unless defined($sub_string); | ||
| 25 | |||
| 26 | my $elmName = $$scaffold[1]; | ||
| 27 | $elmName = '#0' unless $elmName; | ||
| 28 | if ( 'ARRAY' eq ref $$scaffold[1] ) | ||
| 29 | { | ||
| 30 | $next_scaffold = $$scaffold[1]; | ||
| 31 | } | ||
| 32 | elsif ( $elmName =~ /^#(\d*)$/ ) | ||
| 33 | { | ||
| 34 | for (1..$1) | ||
| 35 | { | ||
| 36 | $TidyXML->getMarkedText('TABLE'); # and throw it away. | ||
| 37 | } | ||
| 38 | $next_scaffold = $$scaffold[2]; | ||
| 39 | } | ||
| 40 | else { | ||
| 41 | print STDERR "elmName: $elmName\n" if ($self->ScraperTrace('d')); | ||
| 42 | $next_scaffold = $$scaffold[2]; | ||
| 43 | die "Element-name form of 'TABLE' is not implemented, yet."; | ||
| 44 | } | ||
| 45 | $next_scaffold = undef unless $sub_string = $TidyXML->getMarkedText('TABLE'); | ||
| 46 | return ($next_scaffold, $sub_string, $attributes); | ||
| 47 | } | ||
| 48 | |||
| 49 | |||
| 50 | 1; |