Sayfadaki linkleri bul

Sayfadaki linkleri bul
$html = file_get_contents('http://www.website.com');

$dom = new DOMDocument();
@$dom->loadHTML($html);


$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");

for ($i = 0; $i < $hrefs->length; $i++) {
       $href = $hrefs->item($i);
       $url = $href->getAttribute('href');
       echo $url.'<br />';
}

 

Hakan AK

Son Yazılar