233 |
my @results; |
my @results; |
234 |
my @tags; |
my @tags; |
235 |
|
|
236 |
warn "triplets = ",dump( @triplets ); |
$self->log->debug("looking for $message ", dump( @triplets )); |
|
|
|
237 |
while ( @triplets ) { |
while ( @triplets ) { |
238 |
( $el,$attr,$value ) = splice( @triplets, 0, 3 ); |
( $el,$attr,$value ) = splice( @triplets, 0, 3 ); |
239 |
my $tag = $attr ? "<$el $attr=\"$value\">" : "<$el>"; |
my $tag = $attr ? "<$el $attr=\"$value\">" : "<$el>"; |
240 |
push @tags, $tag; |
push @tags, $tag; |
|
$self->log->debug("looking for $message $tag"); |
|
241 |
@results = $tree->look_down( '_tag', $el, sub { |
@results = $tree->look_down( '_tag', $el, sub { |
242 |
return 1 unless ( $attr && $value ); |
return 1 unless ( $attr && $value ); |
243 |
( $_[0]->attr( $attr ) || '' ) =~ m/\b\Q$value\E\b/ |
( $_[0]->attr( $attr ) || '' ) =~ m/\b\Q$value\E\b/ |
246 |
} |
} |
247 |
|
|
248 |
if ( ! @results ) { |
if ( ! @results ) { |
249 |
my $msg = "can't find $message ", join(" ", @tags); |
my $msg = "can't find $message " . join(" ", @tags); |
250 |
die $msg if ( $fatal ); |
die $msg if ( $fatal ); |
251 |
warn $msg; |
#warn $msg; |
252 |
return; |
return; |
253 |
} |
} |
254 |
|
|
255 |
$self->log->debug("found ", $#results + 1, " results"); |
$self->log->debug("found ", $#results + 1, " elements"); |
|
|
|
256 |
#warn dump( map { $_->as_HTML } @results ); |
#warn dump( map { $_->as_HTML } @results ); |
257 |
|
|
258 |
return @results if wantarray; |
return @results if wantarray; |
398 |
if ( @divs ) { |
if ( @divs ) { |
399 |
|
|
400 |
my $html = join("<hr/>\n", map { $_->as_HTML } @divs ); |
my $html = join("<hr/>\n", map { $_->as_HTML } @divs ); |
401 |
$self->log->debug("found ", $#divs + 1, " element ", length($html), " bytes"); |
$self->log->debug("combined ", $#divs + 1, " elements elements in ", length($html), " bytes"); |
402 |
|
|
403 |
$self->add_record( |
$self->add_record( |
404 |
in_feed => $feed, |
in_feed => $feed, |