copy particular div from Flipkart.com web scraping using Curl and Php -


i want copy particular div contain data flipkart product web page , display it.

<table cellspacing="0" class="spectable"> ///// contains  ///// </table> 

its table value variable in web page have 10 tables in same class , page have more, how can table value ?

also wants specific specsvalue, possible ?

<td class="specskey">brand</td><td class="specsvalue">apple</td> 

web page address: http://www.flipkart.com/apple-iphone-6/p/itme8ra5z7yx5c9j?pid=mobeyhz2jhvfhfbg

sample code

$url = "http://dl.flipkart.com/dl/apple-iphone-6/p/itme8ra5z7yx5c9j?pid=mobeyhz2jhvfhfbg";  $response = getpricefromflipkart($url);  echo json_encode($response);  /* returns response in json format */  function getpricefromflipkart($url) {  $curl = curl_init($url);  curl_setopt($curl, curlopt_useragent, "mozilla/5.0 (windows; u; windows nt 10.10; labnol;) ctrlq.org"); curl_setopt($curl, curlopt_failonerror, true); curl_setopt($curl, curlopt_followlocation, true); curl_setopt($curl, curlopt_returntransfer, true); $html = curl_exec($curl); curl_close($curl);  $regex = '/<meta itemprop="price" content="([^"]*)"/'; preg_match($regex, $html, $price);  $regex = '/<h1[^>]*>([^<]*)<\/h1>/'; preg_match($regex, $html, $title);  $regex = '/data-src="([^"]*)"/i'; preg_match($regex, $html, $image);  if ($price && $title && $image) {      $response = array("price" => $price[1], "title" => $title[1], "image" => $image[1]);  } else {      $response = array("status" => "404", "error" => "we not find product details on flipkart $url");  }  return $response; }  ?> 

flipkart change interface , can fetch product price , using flipkart api. i'm using api.

but want fetch product details using below curl command, if doing same without problem please share else have add here fetch product webpage content, while debugging using getinfo() return 301 moved permanentlywith status code 0

$curl_handle=curl_init(); curl_setopt($curl_handle,curlopt_url,<flipkart_url>); curl_setopt($curl_handle,curlopt_connecttimeout,100); curl_setopt($curl_handle,curlopt_returntransfer,1); curl_setopt($curl_handle, curlopt_referer, 'http://www.flipkart.com/'); curl_setopt($curl_handle, curlopt_useragent, 'mozilla/5.0 (windows; u; windows nt 6.1; en-us; rv:1.9.1.2) gecko/20090729 firefox/3.5.2 gtb5');  $str = curl_exec($curl_handle);          $html = new simple_html_dom();           $html->load($str); 

Comments