The script that works .. I mean gets the desired
search results ...

use IO::Socket;
my $server = "www.google.com";
my $port = 80;
my $document = "/search?hl=en&q=programmer";
my $EOL = "\015\012";
my $BLANK = $EOL x 2;
my $remote = IO::Socket::INET->new(Proto=>"tcp",
PeerAddr=>$server, PeerPort=>$port ,
Timeout=>$timeout)
    or die "Can't connect to \"$server\"\n";
    # set buffering off
    $remote->autoflush(1);
     print $remote "GET $document HTTP/1.0" . $BLANK; 
 
my $line;
while (<$remote>)
{
$line .= $_;
}
close($remote);
 
print $line;


The script that doesn't output the required search
results ...funny till yesterday it never even output
the html which it does now ...prompting me to use
LWP::Debug..but today it outputs some html but not the
desired results..maybe Im passing the contents wrongly
.....

use LWP::UserAgent;
  $ua = new LWP::UserAgent;
  $ua->agent("$0/0.1 " . $ua->agent);

$content = "hl=en&q=programmer";

  $req = new HTTP::Request 'GET' =>
'http://www.google.com/search';
  $req->header('Accept' => 'text/html');
$req->content($content);

  # send request
  $res = $ua->request($req);


  # check the outcome
  if ($res->is_success) {
     print $res->content;
  } else {
     print "Error: " . $res->code . " " .
$res->message;
  }


Thanks

chris


--- Gisle Aas <[EMAIL PROTECTED]> wrote:
> open source devel company
> <[EMAIL PROTECTED]> writes:
> 
> > I tried using LWP to get a page www.google.com...
> > 
> > and my script is 
> > 
> > giving the following message as one of the lines ,
> > when LWP debug is run
> > 
> > LWP::UserAgent::request: Simple response: Internal
> > Server Error
> > 
> > but the same page works using IO::Sockets...
> > 
> > so what seems to be wrong with LWP ?
> 
> Why don't you send us a sample test script?
> 
> 'lwp-request www.google.com' works for me.
> 
> --Gisle


__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

Reply via email to