function pageContent(String $url): \DOMDocument
{
$html = cache()->rememberForever($url, function () use ($url) {
return file_get_contents($url);
});
$parser = new \DOMDocument();
libxml_use_internal_errors(true);
$parser->loadHTML($html);
libxml_use_internal_errors(false);
return $parser;
}
$linkBox is holding a website array which is like this: array(3) {
[0]=>
string(34) "https://lions-mansion.jp/MF161026/"
[1]=>
string(34) "https://lions-mansion.jp/MF171045/"
[2]=>
string(34) "https://lions-mansion.jp/MF171010/"
}
So with foreach I try to go inside the links but I couldn't.
foreach ($linkBox as $box){
$content = pageContent($box);
foreach ($content as $xpathgo){
$Pars = new \DOMXPath($xpathgo);
$Route = $Pars->query("//ul[@id='snav']/li/a");
foreach ($Route as $Rot){
$get = $Rot->getAttribute('href');
}
}
}
var_dump($get);
It returns nothing. Any idea, what the problem is? Thank you for helping!