Goutte icon indicating copy to clipboard operation
Goutte copied to clipboard

How to pick href link and text or complete element

Open danillo10 opened this issue 6 years ago • 1 comments

$noticia = $noticias->filter('article > div > h4 > a')->each(function ($response) { return $response->text(); });

danillo10 avatar Mar 02 '18 15:03 danillo10

Didn't test the code but try something like this.

$crawler->filter($this->productLinkSelector)->each(function($node) {
    $url = $node->attr('href');
    $text = $node->text();
});

For more information feel free to have a look here: https://github.com/FriendsOfPHP/Goutte#more-information

dpde avatar Apr 06 '18 07:04 dpde