LWP::UserAgent problem - 500 error

R

RP

Hi, I'm trying to get the data off of a number of different pages, and
I'm getting an error:

500 Can't connect to www.yahoo.com:80 (connect: Permission denied)

My code is very simple, I'm just trying to get this to work:

#!/usr/bin/perl -w

use strict;
use LWP::UserAgent;

my $url = 'http://www.yahoo.com';
my $browser = LWP::UserAgent->new;
my $response = $browser->get($url,
'User-Agent' => 'compatible; MSIE 6.0; Windows 98',
'Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
image/png, */*',
'Accept-Charset' => 'iso-8859-1,*',
'Accept-Language' => 'en-US',
);

print "Content-type: text/html\n\n";
if ($response->is_success)
{ print $response->content; }
else { print $response->error_as_HTML; }

(Most of this code is copied from Spidering Hacks.) I've been
assuming that the problem is that the headers I'm sending, but I
really don't know - I'm a neophyte with LWP::UserAgent (and most perl
modules, for that matter). Could there be a problem with the response
my server is giving to the request? I've never had any luck getting
LWP::UserAgent/LWP::Simple/HTML::Tokeparser to work on that server,
even extremely simple programs. I've been struggling with this for
weeks, and I'm at a total loss. Help?!?! Thanks a million!
 
M

Matt Garrish

RP said:
Hi, I'm trying to get the data off of a number of different pages, and
I'm getting an error:

500 Can't connect to www.yahoo.com:80 (connect: Permission denied)

My code is very simple, I'm just trying to get this to work:

Did you try running it from the command line on your computer? Would have
proven it's not a problem in the code and saved you some of the headache.

The usual guess is that you have to go through a proxy, but you'll have to
ask your host why you can't connect out.

Matt
 
R

RP

Matt Garrish said:
Did you try running it from the command line on your computer? Would have
proven it's not a problem in the code and saved you some of the headache.

The usual guess is that you have to go through a proxy, but you'll have to
ask your host why you can't connect out.

Matt

Yes, I tried running it from the command line, and I still receive the
500 error. I'll contact my web host and see why I can't connect out -
do you have any idea why that might be? I looked at the Proxy
attributes for LWP::UserAgent, and they are a little confusing.
Thanks for your help - I'll post what I find from my host.
Randy
 
M

Matt Garrish

RP said:
"Matt Garrish" <[email protected]> wrote in message

Yes, I tried running it from the command line, and I still receive the
500 error. I'll contact my web host and see why I can't connect out -
do you have any idea why that might be? I looked at the Proxy
attributes for LWP::UserAgent, and they are a little confusing.
Thanks for your help - I'll post what I find from my host.

I get the yahoo page when I run it. Your host has either configured their
server not to allow any outbound requests, or as I said in my previous post,
they have a proxy you should be going through. No one here can help you with
that, though. If you have a problem running your script once you have the
details of how to connect out, you can always try back then.

Matt
 
R

RP

Matt Garrish said:
I get the yahoo page when I run it. Your host has either configured their
server not to allow any outbound requests, or as I said in my previous post,
they have a proxy you should be going through. No one here can help you with
that, though. If you have a problem running your script once you have the
details of how to connect out, you can always try back then.

Matt

Is it normal for a web host to be configured that way? I've been
considering switching hosts anyway, and this might be the last straw.
I don't want to switch and then have this problem with my new host -
it's a question I have to ask before I find hosting... Thanks for all
your help!
 
G

Gunnar Hjalmarsson

RP said:
Is it normal for a web host to be configured that way?

No, at least not if you are paying for the web space. I think it's not
unusual on 'free' hosts.
I've been considering switching hosts anyway, and this might be the
last straw.

Ask them to help you connect out. If they don't - change hosting provider.
 
M

Matt Garrish

RP said:
"Matt Garrish" <[email protected]> wrote in message

Is it normal for a web host to be configured that way? I've been
considering switching hosts anyway, and this might be the last straw.
I don't want to switch and then have this problem with my new host -
it's a question I have to ask before I find hosting... Thanks for all
your help!

I couldn't say whether it is normal or not, as the majority of web work I do
is at work, where I can do pretty much anything I want... : )

Certainly something you might want to ask of a new host before laying your
money down.

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,696
Latest member
BarbraOLog

Latest Threads

Top