I want to clear the price of a mobile phone from the website URL: http://www.flipkart.com/apple-iphone-5s/p/itmdv6f75dyxhmt4?pid=MOBDPPZZDX8WSPAT
If you are viewing the code, the price is placed in the next SPAN
<div class="pricing line">
<div class="prices" itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
<div>
<span class="selling-price omniture-field" data-omnifield="eVar48" data-eVar48="37500">Rs. 37,500</span> // Fetch this price
</div>
<span class="sticky-message">Selling Price</span>
<meta itemprop="price" content="37,500">
<meta itemprop="priceCurrency" content="INR">
</div>
</div>
My code for this so far is:
<?php
$curl = curl_init('http://www.flipkart.com/apple-iphone-5s/p/itmdv6f75dyxhmt4?pid=MOBDPPZZDX8WSPAT');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$page = curl_exec($curl);
if(!empty($curl)){
$pokemon_doc->loadHTML($curl);
libxml_clear_errors();
$pokemon_xpath = new DOMXPath($pokemon_doc);
$pokemon_row = $pokemon_xpath->query('//h2[@id]');
if($pokemon_row->length > 0){
foreach($pokemon_row as $row){
echo $row->nodeValue . "<br/>";
}
}
}
else
print "Not found";
?>
This shows an error:
Fatal error: calling the loadHTML () member function for a non-object in D: \ xampp \ htdocs \ jiteen \ php-scrape \ phpScrape.php on line 9
What can I do, I can not track the error
source
share