Inugroho has asked for the wisdom of the Perl Monks concerning the following question:
When I ran it, it doesn't output anything. I tried different codes too:#!/usr/bin/perl -w use strict; use LWP; my $browser = LWP::UserAgent->new( ); my $response = $browser->get("http://www.oreilly.com/"); print $response->header("Server"), "\n";
it will output: "Sorry, failed 500: Server closed connection without sending any data back!/usr/bin/perl -w use strict; use URI::Escape; foreach my $word (@ARGV) { next unless length $word; my $url = 'http://www.altavista.com/sites/search/web?q=%22' . uri_escape($word) . '%22&kl=XX'; my ($content, $status, $is_success) = do_GET($url); if (!$is_success) { print "Sorry, failed: $status\n"; } elsif ($content =~ m/>AltaVista found ([0-9,]+) results?/) { # lik +e "1,9 52" print "$word: $1 matches\n"; } else { print "$word: Page not processable, at $url\n"; } sleep 2; } use LWP; my $browser; sub do_GET { $browser = LWP::UserAgent->new unless $browser; my $resp = $browser->get(@_); return ($resp->content, $resp->status_line, $resp->is_success, $resp +) if wantarray; return unless $resp->is_success; return $resp->content; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP error 500 Server closed connection
by esskar (Deacon) on Jul 26, 2005 at 20:22 UTC | |
by Inugroho (Novice) on Jul 26, 2005 at 21:00 UTC | |
by esskar (Deacon) on Jul 26, 2005 at 22:49 UTC | |
by Anonymous Monk on Aug 03, 2005 at 00:35 UTC |