Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LWP UserAgent can't 'get'

Status
Not open for further replies.

cacheung

Programmer
Aug 9, 2005
6
CA
Hi,

Apologies if I am not using the correct terminology.

The only url's that return a response when I LWP::UserAgent->get are local web pages.

I can't seem to 'get' external urls ... well, actually, get times-out.

Does any one know the reasons why this is happening?

Thanks in advance.
C
 
Hi,

Here's the code:
Code:
use LWP::UserAgent;
use Data::Dumper;

my $url = '[URL unfurl="true"]http://www.google.com/';[/URL]
my $ua = LWP::UserAgent->new();
#$ua->timeout(300);
my $response;
$response = $ua->get($url);
#$response = $ua->get($url,
#        'User-Agent'    => 'Mozilla/4.76 [en] (Win98; U)',
#        'Accept'        => 'image/gif, image/x-xbitmap, image/jpeg, 
#image/pjpeg,
# image/png, */*',
#        'Accept-Charset'=> 'iso-8859-1,*,utf-8',
#        'Accept-Language'=> 'en-US',
#);
die "Can't get $url == ", $response->status_line unless $response->is_success;

print Dumper $response;
I got this from an online tutorial ... I just wanted to see how this works. But apparently, it doesn't; not even when I up the timeout.

Any help would be appreciated.
Thanks.
 
The code is working fine for me.
I think it might hav something to do with ur network permissions or some other access problems.
 
Are you behind a firewall?
Does your web access go through a proxy or port mapper of some kind?
Check out your browser and see if it is setup to use a proxy.
Maybe you can use those settings in this script.


Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top