Perl Program to search website and get the data

Posted on 2005-05-13
Last Modified: 2010-03-05
Hi Experts,

  i want to write a perl program to search a website 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,

Question by:sud
    LVL 19

    Accepted Solution

    there is a module, www-search to handle this. It has many front ends to differnent search engines, even the one you want PubMed ( !

    use WWW::Search;

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


    Author Comment

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


    Author Comment

      i have installed the module but it does not give me the output???????

    any suggestion,

    LVL 19

    Expert Comment

    I would test a sample query manually throught the web interface to see that you have a valid seach criteria

    Author Comment

    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,


    Author Comment

    i am fine with B. Thanks,


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
    On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now