I tried to scrape the products details from the website but i got an output as blank page
Here is my code :
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.samsung.com/in/smartphones/galaxy-s/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$dom = new DOMDocument();
@ $dom->loadHTML($result);
$xpath = new DOMXPath($dom);
$name_elements = $xpath->query('//p[@class="pd03-product-card__product-name-text"]');
$price_elements = $xpath->query('//p[@class="pd03-product-card__price-main"]');
$name_array = array();
$price_array = array();
foreach ($name_elements as $name){
$product_name = $name->textContent;
echo "Product Name : " . $product_name . "<br>";
}
foreach ($price_elements as $price){
$product_price = $price->textContent;
echo "Product Price :" . $product_price . "<br>";
}
can anyone help me out how can i resolve this problem