$goutte = new GoutteClient();
$crawler = $goutte->request('GET', 'https://www.website.com');
$reviewContent = $crawler->filter('.review-content');
$rows = $reviewContent->filter('.row');
foreach ($rows as $row) {
$col1 = $row->filter('.col-md-3');
$col2 = $row->filter('.col-md-9');
}
给出错误$col1
我可以使用它来让它工作,但你不能使用break
它,因为它不是真实的for loop
$crawler->filter('.row')->each(function (Crawler $row, $i) {
$col1 = $row->filter('.col-md-3');
$col2 = $row->filter('.col-md-9');
...
...
}