当前节点列表为空."尽管我已经检查过了


"The current node list is empty." even though I've checked it

我正在使用Goutte解析一个带有分页的网站,在我到达最后一页后我遇到了麻烦。

$as = $crawler->filter('tbody > tr > td > a');
if($as->count())
{
    $as->each(function ($node) use (&$URLs)
    {
        $URLs[] = $node->attr('href');
    });
}

我试着检查empty($as), $as->count() > 0,但似乎没有工作。

任何想法?

我找到了答案。我想我的语法错了。它是这样工作的:

$crawler->filter('tbody > tr > td > a')->each(function ($node, $i = 0) use (&$URLs)
            {
                {
                    $URLs[] = $node->attr('href');
                }
            });
相关文章: