adamın yaptığı gibi mükemmel bir şey değil ama mantıken böyle en uzun yazıyı almak daha sonra img lari alip en büyük width*height yapip en büyüğünü bulmak onu ana resim olarak tanimlamak title og:title dan title almak yoksa h1 h2 vs.
fikir versin diye gösteriyorum production amaçlı değildir
<?php
function file_get_contents_curl($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Opera");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function sirala($a,$b) {
if ($a['uzunluk'] == $b['uzunluk']) return 0;
return ($a['uzunluk'] < $b['uzunluk'])? -1 : 1;
}
$html = file_get_contents_curl("http://www.yazmak.org/baumgartnera-hapis-cezasi.html");
$doc = new DOMDocument();
@$doc->loadHTML($html);
$silinecek=array("script","embed","style","object","hr");
foreach($silinecek as $silin)
{
$siltag = $doc->getElementsByTagName($silin);
$siltaglength = $siltag->length;
for ($i = 0; $i < $siltaglength ; $i++) {
$siltag->item(0)->parentNode->removeChild($siltag->item(0));
}
}
$metas = $doc->getElementsByTagName('div');
for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
$veri = trim(str_replace("\n\n","",str_replace(array("\r\n","\x0A\x0A",PHP_EOL . PHP_EOL,"\t"," "),"\n",str_replace(array("<br>","<br />"),PHP_EOL,strip_tags($meta->nodeValue)))),"\n");
$divler[$i]["veri"]= $veri;
$divler[$i]["uzunluk"]= strlen($veri);
}
usort($divler,'sirala');
$divler=array_reverse($divler);
echo '<textarea cols=60 rows=20>'.$divler[0]["veri"].'</textarea>';