To obtain seller ratings, locate the element that displays the seller’s rating, which is often within a span or div tag. Using DOMXPath, you can query this element and extract the rating value.
<?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 seller rating
$rating = $xpath->query('//div[@class="seller-rating"]//span[@class="rating-value"]')->item(0)->nodeValue;
echo "Seller Rating: " . trim($rating) . "\n";
?>