Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3917

Symfony GuzzleHttp Crawler cannot find all elements on the page

$
0
0

I am trying to get data from the amazon product page. But the search for the price always result in The current node list is empty. . The other elements like title are present in the result.

            $jar = new CookieJar();            $url = "https://www.amazon.com/Simple-Mobile-Prepaid-Midnight-Carrier/dp/B07XSQT4Q3";            $client = new Client(['cookies' => $jar,'headers' => ['Host' => 'www.amazon.com','User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.3','Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8','Accept-Language' => 'en-US,en;q=0.5','Accept-Encoding' => 'gzip, deflate, br','Connection' => 'keep-alive','Upgrade-Insecure-Requests' => '1','Cache-Control' => 'max-age=0','TE' => 'Trailers',                ],            ]);$response = $client->request('GET', $url);$crawler = new Crawler($response->getBody()->getContents());$title = $crawler->filter('#productTitle')->text('Product Title couldn\'t be extracted', true);$price = $crawler->filter('#priceblock_ourprice')->text('Product Price couldn\'t be extracted', true);

If trying to run this request with postman the price is present.


Viewing all articles
Browse latest Browse all 3917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>