我有以下代码。
<?php
error_reporting(0);
$url = 'https://www.inmateaid.com/prison-search/all?&page=1';
$output = file_get_contents($url);
$doc = new DOMDocument();
$doc->loadHTML($output);
$selector = new DOMXPath($doc);
$anchors = $selector->query("/html/body//div[@class='media']//div/h4//a");
foreach($anchors as $a)
{
$output = file_get_contents($a->getAttribute("href"));
echo 'hi';
}
?>
如果我们看到下面的代码生成 10 个锚点
$anchors = $selector>query("/html/body//div[@class='media']//div/h4//a");
那么应该如何打印10次呢?但它只能打印3次。
当我在循环中注释该行时,它被打印了 10 次。
我错过了什么吗?
那是
由于max_execution_time = 30
.我增加了时间,问题已解决。