The code below works just fine for me. Try running it. It could be you are missing a dependency or something. What is the exact error message you get?
use strict;
use LWP::UserAgent;
use HTTP::Headers;
my $ua = LWP::UserAgent->new(
'agent' => 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537
+.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'
);
my $hdr = HTTP::Headers->new(
'Content-Type' => 'text/plain',
'Content-Length' => 0,
);
my $url = "https://www.7digital.com/";
my $req = HTTP::Request->new(GET => $url, $hdr);
my $res = $ua->request($req);
if ($res->is_success) {
print $res->decoded_content;
}
else {
die $res->status_line;
}
holli
You can lead your users to water, but alas, you cannot drown them.