Re: LWP : 500 Server closed connection without sending any data back
Irmawaty Nugroh Nugroho wrote: > Hello everyone, > > I have installed ActiveState Perl on my computer, and it has LWP version > 5.803. (I use perl -MLWP -le "print (LWP->VERSION)" > > Right now, I am trying to learn to use LWP. However, LWP doesn't seem to > work. I tried to run a simple program with the following code: ... > This will output: "Sorry, failed 500: Server closed connection without > sending any data back " > Same output for entering this on command prompt: perl -MLWP::Simple -e > "getprint 'http://cpan.org/RECENT'" This works fine for me on XP as does the commandline above - if it's failing for you, you might want to re-install LWP and/or Perl if you can surf to the same locations with your browser (basically the same code) : use strict; use warnings; use LWP; my $UA = LWP::UserAgent->new; my $res = $UA->get("http://www.oreilly.com/";); print $res->header('Server'), "\n"; 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?/) { print "$word: $1 matches\n"; } else { print "$word: Page not processable, at $url\n"; } sleep 2; } sub do_GET { my $UA = LWP::UserAgent->new; my $resp = $UA->get(@_); return ($resp->content, $resp->status_line, $resp->is_success, $resp) if wantarray; return unless $resp->is_success; return $resp->content; } __END__ -- ,-/- __ _ _ $Bill LuebkertMailto:[EMAIL PROTECTED] (_/ / )// // DBE CollectiblesMailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
LWP : 500 Server closed connection without sending any data back
Hello everyone, I have installed ActiveState Perl on my computer, and it has LWP version 5.803. (I use perl -MLWP -le "print (LWP->VERSION)" Right now, I am trying to learn to use LWP. However, LWP doesn't seem to work. I tried to run a simple program with the following code: #!/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"; When I ran it, it doesn't output anything. I tried different codes: !/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?/) { # like "1,952" 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; } This will output: "Sorry, failed 500: Server closed connection without sending any data back " Same output for entering this on command prompt: perl -MLWP::Simple -e "getprint 'http://cpan.org/RECENT'" Please kindly advise on how to solve this problem. Thank you in advanced. Regards, Irma Nugroho ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs