无法使用Symfony DomCrawler从HTML DOM获取文本

时间:2017-06-01 19:58:31

标签: php symfony dom domcrawler

我使用symfony DomCrawler抓取HTML。 我正在提供我需要提取的HTML代码段:

<p class="accounts">
  <b>Account:</b>
  <span class="no-wrap">1234567</span>
  <br>
  <b>Type</b>
  987654
</p>

现在我需要 987654 文字,但我没有成功。 这是我尝试过的:

$dom->filterXPath('//p[@class="accounts"]')->children()->eq(4)->text();
$dom->filterXPath('//p[@class="accounts"]')->children()->eq(4)->html();
$dom->filterXPath('//p[@class="accounts"]')->children()->text();

我能够获得 1234567 ,因为它位于标记下,这就是我所做的:

$dom->filterXPath('//p[@class="accounts"]')->children()->eq(1);

0 个答案:

没有答案