【发布时间】:2018-05-13 01:27:30
【问题描述】:
试图在 div id=firehoselist 中获取 h2 中的所有内容(以获取文章的标题),但以下代码仅返回第一个结果。有什么想法欢迎
$crawler = new Crawler($content);
$crawler->filterXPath('//div[@id="firehoselist"]//*')->each(function (Crawler $node) use (&$results) {
$results[] = trim($node->filter('h2')->text());
});
我要抓取的内容太乱,无法在此处发布,但它来自 slashdot org 网站
【问题讨论】:
标签: symfony dom domcrawler