| 1 | |||
| 2 | use strict; | ||
| 3 | |||
| 4 | package WWW::Scraper::Opcode::OPTION; | ||
| 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 params in the 'OP()' portion of the scaffold. | ||
| 12 | sub new { | ||
| 13 | my ($cls, $scaffold, $params) = @_; | ||
| 14 | my $self = bless {}; | ||
| 15 | $self->{'fieldsDiscovered'} = ['value','caption']; | ||
| 16 | return $self; | ||
| 17 | } | ||
| 18 | |||
| 19 | sub scrape { | ||
| 20 | my ($self, $scraper, $scaffold, $TidyXML, $hit) = @_; | ||
| 21 | |||
| 22 | my $sub_string = $TidyXML->asString; | ||
| 23 | return undef unless $$sub_string =~ s{<OPTION(\s+[^>]*)>(.*?)(<OPTION|</OPTION|$)}{$3}si; | ||
| 24 | |||
| 25 | my $caption = $2; | ||
| 26 | chomp $caption; | ||
| 27 | $hit->caption(\$caption); | ||
| 28 | |||
| 29 | my $attributes = $TidyXML->Attributes($1); | ||
| 30 | |||
| 31 | $hit->value(\$attributes->{'value'}); | ||
| 32 | |||
| 33 | return ($self->_next_scaffold($scaffold), $sub_string, $attributes); | ||
| 34 | } | ||
| 35 | |||
| 36 | |||
| 37 | 1; |