当我尝试从页面中获取一些不存在的内容时,我发现了这个错误:
The current node list is empty.
500 Internal Server Error - InvalidArgumentException
如何安全地检查此内容是否存在?这里有一些不起作用的例子:
if($crawler->filter('.PropertyBody')->eq(2)->text()){
// bla bla
}
if(!empty($crawler->filter('.PropertyBody')->eq(2)->text())){
// bla bla
}
if(($crawler->filter('.PropertyBody')->eq(2)->text()) != null){
// bla bla
}
谢谢,我帮助自己:
$count = $crawler->filter('.PropertyBody')->count();
if($count > 2){
$marks = $crawler->filter('.PropertyBody')->eq(2)->text();
}