Oct 10, 2018
0
Level 1
Parsing images with DomCrawler
Hi all! i'm stuck with a problem with DomCrawler. When I try to do next code:
for($i=0; $i<5; $i++) {
$html = file_get_contents('https://auto.ria.com/legkovie/?page=' . $i);
$crawler = new Crawler($html);
$crawler = $crawler->filterXPath('//div[@class="content-bar"]');
foreach ($crawler as $domElement) {
$crawlerImage = $crawler->filter('img')->attr('src');
var_dump($crawlerImage);
// var_dump($domElement->nodeValue);
echo "<br><br><br>";
}
}
I'm getting list of same links of first image on the page instead of correct ones. How could I fix that?
Please or to participate in this conversation.