FriendsOfPHP / Goutte

Goutte, a simple PHP Web Scraper
MIT License
9.26k stars 1.01k forks source link

How to pick href link and text or complete element #341

Open danillo10 opened 6 years ago

danillo10 commented 6 years ago

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

dpde commented 6 years ago

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