好的,我想尝试使用Goutte从我的博客获得一个标题:
以下代码适用于$ url = https://twoggle.com或https://ninjaforms.com/blog,但不适用于https://twoggle.com/blog/(我已查看来源,我看不到任何内容)应该导致错误?)
$goutteClient = new \Goutte\Client();
$crawler = $goutteClient->request('GET', $url);
$titles = $crawler->filter('html > head > title');
$titles = $titles->each(function ($node, $i) {
echo $node->text();
return $node->text();
});
非常感谢任何帮助!