Perl Program to search website and get the data

Hi Experts,

  i want to write a perl program to search a website http://www.ncbi.nlm.nih.gov/entrez/query.fcgi for some key words, and i want the program to show maximum 10 results, what will be the best method. Any suggestion/ comments will be highly appreciated. Thanks,

Sudhir
sudAsked:
Who is Participating?
 
Kim RyanConnect With a Mentor IT ConsultantCommented:
there is a module, www-search to handle this. It has many front ends to differnent search engines, even the one you want PubMed (www.ncbi.nlm.nih.gov) !

use WWW::Search;

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

0
 
sudAuthor Commented:
Hi ,
 i am getting compilation error,
  i think i dont have WWW::Search module how can i get this module. Thanks,

Sudhir
0
 
sudAuthor Commented:
hi,
  i have installed the module but it does not give me the output???????

any suggestion,

sudhir
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Kim RyanIT ConsultantCommented:
I would test a sample query manually throught the web interface to see that you have a valid seach criteria
0
 
sudAuthor Commented:
I did it with WWW::NCBI::Pubmed, as that is more recent, the WWW::PubMed is old version and does not work properly. Thanks for your response. Thanks,

Sudhir
0
 
sudAuthor Commented:
i am fine with B. Thanks,

Sudhir
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.