I'm trying to get all the links from this site: https://www.supremecourt.uk/cases/search-results.html?q=affidavit
with the following code:
libxml_use_internal_errors(true);
$html = file_get_contents("https://www.supremecourt.uk/cases/search-results.html?q=affidavit");
$docs = new domDocument;
$docs->loadHTML($html);
$anchors = $docs->getElementsByTagName('a');
$links = array();
foreach($anchors as $anchor) {
echo $links[] = $anchor->getAttribute('href');
echo '<br>';
}
but the returned links do not include links from the search results. Why is that, and how can I fix it?