<?php
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$html=file_get_contents('https://example.com/', false, stream_context_create($arrContextOptions));
function getHTML($url,$timeout)
{
$gs = curl_init($url); // initialize curl with given url
curl_setopt($gs, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); // set useragent
curl_setopt($gs, CURLOPT_RETURNTRANSFER, true); // write the response to a variable
curl_setopt($gs, CURLOPT_FOLLOWLOCATION, true); // follow redirects
curl_setopt($gs, CURLOPT_CONNECTTIMEOUT, $timeout); // max. seconds
curl_setopt($gs, CURLOPT_FAILONERROR, 1); // stop if an error is encountered
return @curl_exec($gs);
}
preg_match("/<title[^>]*?>(.*?)<\/title>/si", $html, $match);
echo $match[1];
preg_match("/<h1[^>]*?>(.*?)<\/h1>/si", $html, $description);
echo $description[1];
// Извлекает текст из всех <p>
preg_match_all('/<p[^>]*?>(.*?)<\/p>/si', $html, $matches);
print_r($matches[1]);
?>