You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know it's quite old, but maybe someone needs it.
Just replace the whole sub "recommendation_movies" within Film.pm (worked for me):
sub recommendation_movies {
my CLASS_NAME $self = shift;
my $forced = shift || 0;
if($forced) {
my $parser = $self->_parser(FORCED);
while (my $token = $parser->get_token) {
if ($token->[0] eq 'S' and $token->[1] eq 'div') {
if (exists $token->[2]{id} and $token->[2]{id} eq 'titleRecs') {
$self->_show_message("Jumped to DIV " . $token->[2]{id}, 'DEBUG');
last;
}
}
}
my %result = ();
my $end_tag_counter = 1;
while(my $tag = $parser->get_tag()) {
$end_tag_counter++ if $tag->[0] eq 'div';
$end_tag_counter-- if $tag->[0] eq '/div';
my $text = $parser->get_text();
if($tag->[0] eq 'a' && $text && $tag->[1]{href} && $tag->[1]{href} =~ /tt(\d+)/) {
$result{$1} = $text;
}
last if $end_tag_counter le '0';
}
$self->{_recommendation_movies} = \%result;
}
return $self->{_recommendation_movies};
}
The first while loop moves forward within the IMDb page until the div tag with id 'titleRecs'.
Then we need a counter for nested div tags to jump to last if it reaches 0 again.
And i removed an 'Use of uninitialized value in pattern match' warning by adding another check if $tag->[1]{href} is initialized before using it in the pattern match.
This call always returns a empty result:
$imdbObj->recommendation_movies()
The text was updated successfully, but these errors were encountered: