我正在尝试抓取以下内容,我基本上想要文本和链接,我正在使用Goutte和 PHP。我可以使用以下代码很好地获取文本,但无法获取 href 值。任何帮助都会很棒。
$crawler->filter('#most-popular > div > ol > li > a')->each(function ($node) {
var_dump($node->getAttribute('href'));
});
<li class="first-child ol1">
<a href="http://www.bbc.co.uk/news/uk-england-south-yorkshire-31895703" class="story">
<span class="livestats-icon livestats-1">1: </span>MP claims £17 poppy wreath expenses</a>
</li>