H
Hon Guin Lee - Web Producer - SMI Marketing
Hi all,
The LWP::get() function manages to retrieve some of the localised web document content from local web servers displayed on my web browser using Mozilla 1.1, for URL's without the www.
However for URLs that begin with www, the get() functon just returns an undef (shown in subroutine get_url) hence the web browser unables to display the web content.
To narrow the problem further, I used some of the other functions such as getstore(url,file) and mirror(url,file) where I replace url with shift, and a filename specified, but the LWP:ebug just throws up: -
--------------------------------------------------------------------------
LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP:rotocol::collect: read 57 bytes LWP::UserAgent::request: Simple response:
Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/location.jsp LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP:rotocol::collect: read 19 bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp?location=Non-US LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP:rotocol::collect: read 57
bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/cachedir/cachedtab_Non-US_NEWS.html LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
--This is a URL specifed for the local web server requesting some form of proxy.
--------------------------------------------------------------------------
LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://www.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
--This is a URL specified for a www web docuument.
--------------------------------------------------------------------------
Any solutions/reasons why the get() function cannot retrieve unlocalised web content?
Here is the script: -
--------------------------------------------------------------------------
#!/usr/local/perl5.6/bin/perl -wT
# perl script to get remote
# urls and strip them and
# upload them to teamsite
use LWP::Simple qw(!head);
use LWP:ebug '+';
use CGI qwstandard); # then only CGI.pm defines a head()
use strict;
print "Content-type: text/html\n\n";
my $old_handle;
$|++; #sets $| for STDOUT
$old_handle = select( STDERR ); #change to STDERR
$|++; #sets $| for STDERR
select( $old_handle ); #change back to STDOUT
my ($url) = @_;
my $lang;
process_form();
get_url($url);
# Passes the data from the server,
# and takes them onto the PERL script.
sub process_form {
$url = param('url');
$url = "http://$url";
$lang = param('lang');
}
# Retrieves the contents of the
# specified URL.
sub get_url {
my $page = get(shift);
unless (defined $page) {
print "Couldn't retrieve $url";
}
else {
print "$page\n";
}
}
--------------------------------------------------------------------------
The LWP::get() function manages to retrieve some of the localised web document content from local web servers displayed on my web browser using Mozilla 1.1, for URL's without the www.
However for URLs that begin with www, the get() functon just returns an undef (shown in subroutine get_url) hence the web browser unables to display the web content.
To narrow the problem further, I used some of the other functions such as getstore(url,file) and mirror(url,file) where I replace url with shift, and a filename specified, but the LWP:ebug just throws up: -
--------------------------------------------------------------------------
LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP:rotocol::collect: read 57 bytes LWP::UserAgent::request: Simple response:
Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/location.jsp LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP:rotocol::collect: read 19 bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp?location=Non-US LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP:rotocol::collect: read 57
bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/cachedir/cachedtab_Non-US_NEWS.html LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
--This is a URL specifed for the local web server requesting some form of proxy.
--------------------------------------------------------------------------
LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://www.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP:rotocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
--This is a URL specified for a www web docuument.
--------------------------------------------------------------------------
Any solutions/reasons why the get() function cannot retrieve unlocalised web content?
Here is the script: -
--------------------------------------------------------------------------
#!/usr/local/perl5.6/bin/perl -wT
# perl script to get remote
# urls and strip them and
# upload them to teamsite
use LWP::Simple qw(!head);
use LWP:ebug '+';
use CGI qwstandard); # then only CGI.pm defines a head()
use strict;
print "Content-type: text/html\n\n";
my $old_handle;
$|++; #sets $| for STDOUT
$old_handle = select( STDERR ); #change to STDERR
$|++; #sets $| for STDERR
select( $old_handle ); #change back to STDOUT
my ($url) = @_;
my $lang;
process_form();
get_url($url);
# Passes the data from the server,
# and takes them onto the PERL script.
sub process_form {
$url = param('url');
$url = "http://$url";
$lang = param('lang');
}
# Retrieves the contents of the
# specified URL.
sub get_url {
my $page = get(shift);
unless (defined $page) {
print "Couldn't retrieve $url";
}
else {
print "$page\n";
}
}
--------------------------------------------------------------------------