R
Rajesh
Hi,
I checked the archives and faq in Perl. ostly from the archives, I got
to put up the following code to read from an url. But, if i run this
code i get the error,
500: Can't connect to www.yahoo.com:80 ((Bad hostname www.yahoo.com)
I believe it has something to do with internet connectivity. But, i
can acces the page using Internet explorer. So, do i have to specify
some proxy or something in the program?
Or is something wrong with the script?
P.S... I am running the perl script in Windows XP.
#!/usr/local/bin/perl -w
use LWP::Simple;
use LWP::UserAgent;
$url = "http://www.yahoo.com";
$ua = new LWP::UserAgent;
$ua->agent("$0/0.1");
$req = new HTTP::Request 'HEAD', $url;
$req->header('Accept' => 'text/html');
# send request
$res = $ua->request($req);
# check the outcome
if ($res->is_success) {
print "The link <$url> is ok.\n";
} else {
print "<$url>\n";
print " " . $res->code . " " . $res->message . "\n\n";
}
Rajesh
I checked the archives and faq in Perl. ostly from the archives, I got
to put up the following code to read from an url. But, if i run this
code i get the error,
500: Can't connect to www.yahoo.com:80 ((Bad hostname www.yahoo.com)
I believe it has something to do with internet connectivity. But, i
can acces the page using Internet explorer. So, do i have to specify
some proxy or something in the program?
Or is something wrong with the script?
P.S... I am running the perl script in Windows XP.
#!/usr/local/bin/perl -w
use LWP::Simple;
use LWP::UserAgent;
$url = "http://www.yahoo.com";
$ua = new LWP::UserAgent;
$ua->agent("$0/0.1");
$req = new HTTP::Request 'HEAD', $url;
$req->header('Accept' => 'text/html');
# send request
$res = $ua->request($req);
# check the outcome
if ($res->is_success) {
print "The link <$url> is ok.\n";
} else {
print "<$url>\n";
print " " . $res->code . " " . $res->message . "\n\n";
}
Rajesh