#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Curl::Easy;
use Data::Dump;
my $fetch = sub {
my $curl = WWW::Curl::Easy->new();
my ( $header, $body );
$curl->setopt( CURLOPT_URL, shift );
$curl->setopt( CURLOPT_WRITEHEADER, \$header );
$curl->setopt( CURLOPT_WRITEDATA, \$body );
$curl->setopt( CURLOPT_FOLLOWLOCATION, 1 );
$curl->setopt( CURLOPT_TIMEOUT, 10 );
$curl->setopt( CURLOPT_SSL_VERIFYPEER, 1 );
$curl->perform;
{
header => $header,
body => $body,
info => $curl->getinfo(CURLINFO_HTTP_CODE),
error => $curl->errbuf,
};
};
my $result = $fetch->(shift);
dd $result;
__END__
####
karls-mac-mini:playground karl$ ./curl.pl https://sharecenter.com/Pages/Software.aspx
{
body => undef,
error => "SSL peer certificate or SSH remote key was not OK",
header => undef,
info => 0,
}
####
karls-mac-mini:playground karl$ ./curl.pl https://sharecenter.com/Pages/Software.aspx
{
body => "",
error => "",
header => "HTTP/1.0 200 OK\r\nDate: Mon, 22 Jan 2018 09:47:51 GMT\r\nServer: Apache/2.2.22\r\nExpires: Mon, 26 Jul 1997 05:00:00 GMT\r\nLast-Modified: Mon, 22 Jan 2018 09:47:51 GMT\r\nCache-Control: no-store, no-cache, must-revalidate\r\nCache-Control: post-check=0, pre-check=0\r\nPragma: no-cache\r\nSet-Cookie: tu=dc6816b4e45149c7421e46e39052dfef; expires=Tue, 31-Dec-2019 23:00:00 GMT; Max-Age=61218729; path=/; domain=sharecenter.com; httponly\r\nX-Adblock-Key: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANnylWw2vLY4hUn9w06zQKbhKBfvjFUCsdFlb6TdQhxb9RXWXuI4t31c+o8fYOv/s8q1LGPga3DE1L/tHU4LENMCAwEAAQ==_heva/qNbVoSrOKfx6K0UI/DeonTq8ke19pivgTgrL2w9ZtF3/lPIuu2AIlia5FA69jmNJzQb9Afod5WU1oglQw==\r\nVary: Accept-Encoding\r\nContent-Length: 11\r\nContent-Type: text/html; charset=UTF-8\r\nX-Cache: MISS from 110132\r\nConnection: close\r\n\r\n",
info => 200,
}