How can I safely check is node empty or not? (Symfony 2 Crawler)

前端 未结 3 711
-上瘾入骨i
-上瘾入骨i 2021-02-05 03:53

When I try to take some nonexistent content from page I catch this error:

The current node list is empty.
500 Internal Server Error - InvalidArgumentException 
<         


        
3条回答
  •  一向
    一向 (楼主)
    2021-02-05 04:36

    $marks = $crawler->filter('.PropertyBody')->count()
        ? $crawler->filter('.PropertyBody')->eq(2)->text() 
        : '';
    

提交回复
热议问题