I am trying to download this page :
https://www.nawaiwaqt.com.pk/national
using curl.
getting error :
Download un-successful : error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure
The code I am using is:
<?php
$url ="https://www.nawaiwaqt.com.pk/national";
function curl_download($Url){
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
$output = curl_exec($ch);
if (!$output) {
exit("Download un-successful : ".curl_error($ch));
}
return $output;
}
// $url is any url
$source=curl_download($url);
$d=new DOMDocument();
$d->loadHTML($source);
$title=$d->getElementsByTagName("title")->item(0)->textContent;
$domx = new DOMXPath($d);
$desc=$domx->query("//meta[@name='description']")->item(0);
$description=$desc->getAttribute('content');
?>
New contributor
Hardcode is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.