How to get meta description content using Goutte
Asked Answered
T

1

6

Can you please help me to find a way to get a content from meta description, meta keywords and robots content using Goutte. Also, how can I target <link rel="stylesheet" href=""> and <script>?

Below is PHP that I used to get <title> content:

require_once 'goutte.phar';

use Goutte\Client;

$client = new Client();


$crawler = $client->request('GET', 'http://stackoverflow.com/');

$crawler->filter('title')->each(function ($node) {
$content .= "Title: ".$node->text()."";
echo $content;
});

Here is a link to Goutte - https://github.com/fabpot/goutte

Tega answered 26/3, 2014 at 23:7 Comment(0)
D
10

You can use:

$crawler->filterXpath('//meta[@name="description"]')->attr('content');
Deadlock answered 11/9, 2014 at 8:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.