-
Scrape product specifications, seller ratings, delivery option Carrefour Brazil?
To extract product specifications from Carrefour Brazil, you can use PHP with cURL to fetch the page content and DOMDocument to parse the HTML. Specifications are often listed in a table or a series of div elements. By navigating through the DOM, you can retrieve these details.
<?php // Initialize cURL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.carrefour.com.br/produto-page'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $html = curl_exec($ch); curl_close($ch); // Load HTML into DOMDocument $dom = new DOMDocument; libxml_use_internal_errors(true); $dom->loadHTML($html); libxml_clear_errors(); // Create XPath to navigate DOM $xpath = new DOMXPath($dom); // Extract product specifications $specs = $xpath->query('//div[@class="product-specifications"]//li'); foreach ($specs as $spec) { echo trim($spec->nodeValue) . "\n"; } ?>
Log in to reply.