Q:

How to get data from multiple URLs using curl in php? 

I am trying to fetch some details of multiple products, The below code is for single URL and It's working fine:-
<? php
$url = "http://www.flipkart.com/healthgenie-hd-221-digital-black-dotted-weighing-scale/p/itmeatqzeehkdsmg";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($curl);
curl_close($curl);

$dom = new DOMDocument;
libxml_use_internal_errors(true);
$dom->loadHTML($output);
libxml_clear_errors();
$xpath = new DOMXpath($dom);

// Product Name
$find_product_name = $xpath->query('//h1[@class="title"]');
if($find_product_name->length > 0)
{
    $product_name= $find_product_name->item(0)->nodeValue;
}
else
{
    $product_name="Product Name Not Found";
}

// Sold by
$find_seller = $xpath->query('//a[@class="seller-name"]');
if($find_seller->length > 0)
{
    $seller= $find_seller->item(0)->nodeValue;
}
else
{
    $seller="Seller Not Found";
}

// List Price
$find_list_price = $xpath->query('//span[@class="price"]');
if($find_list_price->length > 0)
{
    $list_price= $find_list_price->item(0)->nodeValue;
}
else
{
    $list_price="Not Available";
}

// Sale Price
$find_sale_price = $xpath->query('//span[@class="selling-price omniture-field"]');
if($find_sale_price->length > 0)
{
    $sale_price= $find_sale_price->item(0)->nodeValue;
}
else
{
    $sale_price="Not Available";
}

// Stock Status
$find_stock = $xpath->query('//div[@class="out-of-stock-status"]');
if($find_stock->length > 0)
{
    $stock= $find_stock->item(0)->nodeValue;
}
else
{
    $stock = "In Stock!"; 
}
 // 
? >

<table width="100%" align="center" border="1">
<tr>
<th>Product Name</th>
<th>Sold By</th>
<th>List Price</th>
<th>Sale Price</th>
<th>Stock Status</th>
</tr>

<tr>
<td><?php echo '<a href="'.$url.'"  target="_blank">'.$product_name. '</a>'; ? ></td>
<td><?php echo $seller; ? ></td>
<td><?php echo $list_price; ? ></td>
<td><?php echo $sale_price; ? ></td>
<td><?php echo $stock; ? ></td>
</tr>
</table>

Now i need a way to fetch data from multiple URLs at once.  I want the same process for the multiple URLs ny taking the URLs in array.. For example:-
<? php
$url = array(
"http://www.flipkart.com/healthgenie-hd-221-digital-black-dotted-weighing-scale/p/itmeatqzeehkdsmg",
"http://www.flipkart.com/healthgenie-hd-221-digital-black-dotted-weighing-scale/p/itmeatqzeehkdsmg",
"http://www.flipkart.com/healthgenie-hd-221-digital-black-dotted-weighing-scale/p/itmeatqzeehkdsmg"
);
? >

I request all the developers to please have a look and help me regarding this.  Many thanks in Advance.  

A:

Put the URL in CSV and create a upload form. 
<? php
$fsn = fopen($_FILES['fsn']['tmp_name'], 'r');
if(!$fsn)
{
    die('Cannot open uploaded file.'); 
}
while (($data = fgetcsv($fsn)) ! == FALSE)
{
    $urls[] = $data[0];
}

foreach($urls as $url)
{
    // Execute the code
}
? >

