Trying to get the default price for the product from these two link ex:
link 1 - https://www.amazon.com/Apple-MacBook-15-inch-256GB-Storage/dp/B07RZWRHTS/
link 2 - https://www.amazon.com/gp/product/B013GVDTI4/
using GuzzleHttp and Crawler I can get successfully the price from link 1 using this:
$jar = new CookieJar();
$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' => 'close',
'Upgrade-Insecure-Requests' => '1',
'Cache-Control' => 'max-age=0',
'TE' => 'Trailers',
],
]);
$response = $client->request('GET', $url);
$crawler = new Crawler($response->getBody()->getContents());
$price = $crawler->filter('#priceblock_ourprice')->text(0, true);
The second link return empty node
'nodes' =>
array (size=0)
empty
The page structure almost the same when opening in the browser both prices are present. Any ideas why is that?