stepanov / IMDB-Film

IMDB::Film module
http://search.cpan.org/~stepanov/
Other
3 stars 4 forks source link

First entry in search results is not a search result #5

Open andy71 opened 6 years ago

andy71 commented 6 years ago

Hi there,

every time when I tried to search for a movie, the first entry was completely different from my search. Just as an example, today I searched with crit => "Electric Dreams" (movie from 1984) and the first result was "Die Ritter der Kokosnuß" (engl. "Monty Python and the Holy Grail" from 1975). screenshot - 10 08 2018 - 15 02 24

After taking a look on the search result I found this "result" within the navigation menu as a recommendation. screenshot - 10 08 2018 - 14 42 02

I am wondering that no one else seems to have this issue?

After studying the codes of IMDB-Film and digging into the source code of the IMDb results page, I found a solution which seems to work for me. All real results where inside a DIV with the class "findSection". So I added this part of code within BaseClass.pm inside the sub "_search_results" behind this line my $parser = $self->_parser();

    while (my $token = $parser->get_token) {
        if ($token->[0] eq 'S' and $token->[1] eq 'div') {
            if (exists $token->[2]{class} and $token->[2]{class} eq 'findSection') {
                $self->_show_message("Jumped to DIV " . $token->[2]{class}, 'DEBUG');
                last;
            }
        }
    }

This little snippet just moves forward within $parser until it founds a div with class 'findSection'. After this your code works like a charm (as far as I checked this).