1

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?

serj
  • 193
  • 1
  • 3
  • 19
  • I don't have a machine that I can test on right now, but I would recommend saving the HTML to disk first so that you can inspect it and compare if it has the same as what your browser has. – Chris Haas Jun 12 '20 at 21:02
  • yes, there is a difference in the output HTML there is no block with price in one of them, also if I enter on this link through incognito mode there is also no price only button with "Available from these sellers.", maybe it's something due to my headers request? – serj Jun 13 '20 at 15:56

0 Answers0