php – 如何使用Goutte获取元描述内容
发布时间:2020-12-13 21:51:07 所属栏目:PHP教程 来源:网络整理
导读:你能帮我找到一种方法,使用Goutte从元描述,元关键词和机器人内容中获取内容.另外,我如何定位 link rel =“stylesheet”href =“”和 script? 下面是我以前获得的PHP title内容: require_once 'goutte.phar';use GoutteClient;$client = new Client();$cra
你能帮我找到一种方法,使用Goutte从元描述,元关键词和机器人内容中获取内容.另外,我如何定位< link rel =“stylesheet”href =“”>和< script>?
下面是我以前获得的PHP< title>内容: require_once 'goutte.phar'; use GoutteClient; $client = new Client(); $crawler = $client->request('GET','https://stackoverflow.com/'); $crawler->filter('title')->each(function ($node) { $content .= "Title: ".$node->text().""; echo $content; }); 这是Goutte – https://github.com/fabpot/goutte的链接 解决方法
您可以使用:
$crawler->filterXpath('//meta[@name="description"]')->attr('content'); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |