C
CronJob
How can I keep LWP::UserAgent from adding the http-equiv strings from
the Head section of the page? When I run the following program below,
the $headers variable contains three Content-Type: listings. One from
the actual http header and one from the meta tag in the web page.
#!/usr/bin/perl -w
use LWP::UserAgent;
use HTML:arse;
use HTML::Element;
use HTTP::Response;
use HTTP::Request;
use HTTP::Status;
use URI::URL;
my ($code, $desc, $headers, $body)=&makeRequest('GET', 'http://
www.google.com');
print "The headers:\n$headers\n";
print "The body:\n$body\n";
sub makeRequest( ) {
($method, $path) = @_;
# create a user agent object
my $ua = new LWP::UserAgent;
$ua->agent("Mozilla/4.0");
# request a url
my $request = new HTTP::Request($method, $path);
# set values in response object HTTP::Reponse
my $response = $ua->request($request);
# get the details if there is an error
# otherwise parse the response object
my $body=$response->content;
my $code=$response->code;
my $desc=HTTP::Status::status_message($code);
my $headers=$response->headers_as_string;
$body = $response->error_as_HTML if ($response->is_error);
return ($code, $desc, $headers, $body);
}
the Head section of the page? When I run the following program below,
the $headers variable contains three Content-Type: listings. One from
the actual http header and one from the meta tag in the web page.
#!/usr/bin/perl -w
use LWP::UserAgent;
use HTML:arse;
use HTML::Element;
use HTTP::Response;
use HTTP::Request;
use HTTP::Status;
use URI::URL;
my ($code, $desc, $headers, $body)=&makeRequest('GET', 'http://
www.google.com');
print "The headers:\n$headers\n";
print "The body:\n$body\n";
sub makeRequest( ) {
($method, $path) = @_;
# create a user agent object
my $ua = new LWP::UserAgent;
$ua->agent("Mozilla/4.0");
# request a url
my $request = new HTTP::Request($method, $path);
# set values in response object HTTP::Reponse
my $response = $ua->request($request);
# get the details if there is an error
# otherwise parse the response object
my $body=$response->content;
my $code=$response->code;
my $desc=HTTP::Status::status_message($code);
my $headers=$response->headers_as_string;
$body = $response->error_as_HTML if ($response->is_error);
return ($code, $desc, $headers, $body);
}