Perl Home Search CGI

2.1 CGI GET method


14.02.2006

2 LWP [  up  ] - [ top ] 2.2 CGI POST method

print "Content-type: text/plain\n\n";

eval("use LWP::UserAgent");
if ($@) {
	print "no such Module on this host";
	exit;
}

my $ua = LWP::UserAgent->new(agent => $ENV{SCRIPT_NAME});

my $r = HTTP::Request->new('GET', 'http://www.blick.ch');
my $response = $ua->request($r);

unless ($response->is_success) {
	print $response->error_as_HTML . "\n";
	print "Could not connect to server\n";
	exit(1);
}

my $Result = $response->content(); # content without HTTP header

print $Result;

copyright by reto - created with mytexi