dannoura has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm using WWW::Search with the backend WWW::Search::PubMed to try and search this site. The problem is that I get absolutely nothing when I run this:

#! c:\perl\bin use WWW::Search; $query = "lung cancer treatment"; $search = new WWW::Search('PubMed'); $search->native_query(WWW::Search::escape_query($query)); $search->maximum_to_retrieve(100); while (my $result = $search->next_result()) { $url = $result->url; $title = $result->title; $desc = $result->description; print "$result\n"; print "<a href=$url>$title<br>$desc<p>\n"; }

I know that the WWW::Search module recognizes the search engine because I checked out the content of $engine. This is a tough one because there's no error I can look into. The script runs but retrieves no data. When I do the search manually by going to the page I do get results.

Any suggestions?

Replies are listed 'Best First'.
Re: problem with search module
by Lachesis (Friar) on Jul 02, 2003 at 10:46 UTC
    WWW:Search gives you a response method which will return the HTTP::Response object for the most recent query. Inspect that to see if that sheds any light on your problem.
    my $response = $search->response(); if ($response->is_success) { print "Page returned ok"; } else { print "error: " . $response->as_string(); }

      OK, thanks, I tried it and it returns:

      Page returned ok

      Any other ideas?

        In that case the page will have been a valid response page so you could grab the content and visually check it. The actual HTML might give you a clue as to what happened, grab it with the $response->as_string();
        You could also get hold of the request object that was used for the search via $response->request();