คือผมอยากรู้ว่า file ้ html ที่สร้างมาจาก url อะไร อยากเก็บไว้เป็น array อ่ะครับ
Code (PHP)
function curl($url){
$urls = split("</br>",$url);
$filter=array_filter($urls);
$text=array_unique($filter);
// create the multi curl handle
$mh = curl_multi_init();
$handles = array();
for($i=0;$i<count($text);$i++){
// create a new single curl handle
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$text[$i]?seconds=".($i+1));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// add this handle to the multi handle
curl_multi_add_handle($mh,$ch);
// put the handles in an array to loop this later on
$handles[] = $ch;
}
// execute the multi handle
$running=null;
do{
curl_multi_exec($mh,$running);
// added a usleep for 0.25 seconds to reduce load
usleep (250000);
} while ($running > 0);
// get the content of the urls (if there is any)
for($i=0;$i<count($handles);$i++){
// get the content of the handle
$output = curl_multi_getcontent($handles[$i]);
$tmpfname = tempnam("C:/AppServ/www/coppae/url", "url_");
$objFopen = fopen("$tmpfname.html", 'w');
fwrite($objFopen, $output);
if($objFopen)
{
//echo "File writed.";
}else{
//echo "File can not write";
}
fclose($objFopen);
// remove the handle from the multi handle
curl_multi_remove_handle($mh,$handles[$i]);
}
curl_multi_close($mh);
}