【发布时间】:2019-09-26 07:28:05
【问题描述】:
所以尝试使用 Symfony DomCrawler 获取 html 标签的文本内容
<html>
<strong> This is a strong text </strong>
<strong> This is a strong text </strong>
<h2> this is a header 2 text </h2>
</html>
所以目标是获取例如强 2 标签内的文本
我正在这样做,但它不起作用我收到节点列表为空的错误:
$ExtractText = $crawler->filter('strong')->eq(2)->text();
【问题讨论】:
-
“但它不起作用”是什么意思?空白页?获取了错误的元素?
-
出错(节点列表为空)
-
以上是您正在使用的实际 HTML 还是出于问题目的的摘录?
-
这只是这篇文章的一个例子,我在 bootstrap 上使用完整的 html 页面
标签: php html symfony web-scraping domcrawler