| 1 | |||
| 2 | use strict; | ||
| 3 | |||
| 4 | package WWW::Scraper::Opcode::INPUT; | ||
| 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 | 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','type','value','caption']; | ||
| 21 | return $self; | ||
| 22 | } | ||
| 23 | |||
| 24 | sub scrape { | ||
| 25 | my ($self, $scraper, $scaffold, $TidyXML, $hit) = @_; | ||
| 26 | |||
| 27 | my $sub_string = $TidyXML->asString; | ||
| 28 | return undef unless $$sub_string =~ s{<INPUT(\s*[^>]*)>([^<]*)}{}si; | ||
| 29 | |||
| 30 | my $caption = $2; | ||
| 31 | chomp $caption; | ||
| 32 | |||
| 33 | my $attributes = $TidyXML->Attributes($1); | ||
| 34 | |||
| 35 | return ($$scaffold[1], $$sub_string, $attributes); | ||
| 36 | } | ||
| 37 | |||
| 38 | 1; |