我使用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);