I'm parsing some news from one of the Turkish Health Ministry's websites. But for instance if website is down now or can't be loaded, my website doesn't load the content after the part that i parse the news. Is there a way to reduce the parsing time ( because of the problem, my website gets loaded in 1 minute nearly ) and if it returns null, just write something like, can't make connection or something like that error message ?
<?php
$html = file_get_html('http://www.tkhk.gov.tr/TR,6/duyurular.html');
$i = 0;
foreach($html->find('a.belge_alt_b') as $element2){
echo "<div class=\"post\">
<div class=\"matter\">
<h3><a target=\"_blank\" href=\"http://www.tkhk.gov.tr".$element2->href." \">". $element2->plaintext . "</a></h3>
</div>
</div>
";
$i++ ;
if($i > 4) break;
}
?>