Encontrar todos los links de una página con PHP
Escrito por Josep Viciana hace 10 meses
No hay mucho que decir sobre esto… sólo dejar el código:
$html = file_get_contents('http://www.example.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.'';
}
Visto en css-tricks