Forum Moderators: coopster & phranque

Message Too Old, No Replies

Error: "500 Can't connect to www.yahoo.com:80 (connect: Unknown error)

         

subha

6:59 am on Jun 13, 2008 (gmt 0)

10+ Year Member



I am trying to open a web page by using LWP.

Below are the codes used to execute this program:

#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $browser = LWP::UserAgent->new( );
my $url = 'http://www.yahoo.com/';
my $response = $browser->get($url);
die "Hmm, error \"", $response->status_line( ),
"\" when getting $url" unless $response->is_success( );
my $content_type = $response->content_type( );
die "Hm, unexpected content type $content_type from $url"
unless $content_type eq 'text/html';
my $content = $response->content( );
die "Odd, the content from $url is awfully short!"
if length($content) < 3000;

While executing this program, i am getting this error message:
error "500 Can't connect to www.yahoo.com:80 (connect: Unknown error)"

Even, i tried to disable the firewall and stopped the firewall service.. still, the same problem exists.

Any help is appreciated...

perl_diver

5:48 pm on Jun 13, 2008 (gmt 0)

10+ Year Member



Are you going through a proxy server maybe? Your code produces no output at all for me. Also, yahoo may block access from "unfriendly" bots, which your code is as it does not identify itself in any way. Try defining a browser type in the new() method. See LWP::UserAgent for details.

masidani

3:36 pm on Jun 20, 2008 (gmt 0)

10+ Year Member



Does sound like a proxy server problem. I can get your code to work - i.e, no errors, but no output either - when I configure the useragent object using the proxy method for my proxy server. For example, after the line
my $browser = LWP::UserAgent->new( );
I added
$browser->proxy('http','http://www.MYPROXY.COM:3128');

where www.MYPROXY.COM:3128 is meant to represent the address and port number of my proxy server.