ANJAN PURKAYASTHA wrote:
Hi,
Here is a beginner's LWP code that is not working. The script is supposed to
query the NCBI website with a user defined term: tuberculosis.  The term is
entered into a search box. The user chooses a database from a drop-down menu
and then hits the Search button.
Here is the code:
#!/usr/bin/perl -w
use strict;
use LWP;

my $query= "tuberculosis";
my $option= "30";
my $go= "Go";
my $site= "NcbiHome";
my $ua= LWP::UserAgent->new;
my $response= $ua->post('http://www.ncbi.nlm.nih.gov/',
            [
            "term"=> $query,
            "db"=> "4", # use the Genome database (value=4)
            "submit"=> "Go",
            "SITE"=> "NcbiHome"
            ]
                        );

if ($response->is_success) {
     print $response->content()."\n";  # or whatever
 }
 else {
     die $response->status_line;
 }

All this script returns is the NCBI homepage.
Any idea what I am doing wrong?

- You are not posting the request to the script that handles search
  queries.

- The site deals with cookies, and it's possible that the script
  requires one or more cookie to be sent as part of the request.

Those are two obvious things, but there might be more into it. Why not simply ask them?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to