I want to get list of both img
and a
from a website. I used the following code.
use Goutte\Client;
...
..
.
$client = new Client();
$url = 'https://edition.cnn.com/';
$page = $client->request('GET', $url);
$page->filter('img', 'a')->each(function ($item) use ($url) {
dump($item->getNode(0));
});
However, it only shows the img
; not a
. If I use $page->filter('a')
then I get all links. How can I get both imgs and as using one filter?
CodePudding user response:
just replace filter('img', 'a')
with filter('img, a')
.