写这个:
$likes = $xpath->query('//span[@class="LikesCount"]');
这是我得到的:
155 like
我想编写查询以便 number_before_like > 5
$likes = $xpath->query('
((int)substring-before(//span[@class="LikesCount"], " ")) > 5
');
遵循标记:
<div class="pin">
[...]
<a href="/pin/56787645270909880/" class="PinImage ImgLink">
<img src="http://media-cache-ec3.pinterest.com/upload/56787645270909880_d7AaHYHA_b.jpg" alt="Krizia" data-componenttype="MODAL_PIN" class="PinImageImg" style="height: 288px;">
</a>
<p class="stats colorless">
<span class="LikesCount">
2 likes
</span>
<span class="RepinsCount">
6 repins
</span>
</p>
[...]
</div>