如下所示:
复制代码 代码如下:
1,
curlopt_followlocation=>1,
curlopt_header => false,
curlopt_httpheader => array(
'accept'=>' text/html, application/xhtml+xml,',
'accept-encoding'=>' gzip, deflate',
'accept-language'=>' zh-cn',
'connection'=>' keep-alive',
'user-agent'=>' mozilla/5.0 (compatible; msie 9.0; windows nt 6.1; trident/5.0)',
),
);
function curlmultirequest($urls,$options=array()){
$ch = array();
$results = array();
$mh = curl_multi_init();
foreach($urls as $key=>$val){
$ch[$key] = curl_init();
if($options){
curl_setopt_array($ch[$key],$options);
}
curl_setopt($ch[$key],curlopt_url,$val);
curl_multi_add_handle($mh,$ch[$key]);
}
$running = null;
do{
curl_multi_exec($mh,$running);
}while($running>0);
foreach($ch as $key=>$val){
//$results[$key] = iconv('gb2312','utf-8',curl_multi_getcontent($val));
$results[$key] = curl_multi_getcontent($val);
curl_multi_remove_handle($mh,$val);
curl_close($val);
}
curl_multi_close($mh);
return $results;
}
$results = curlmultirequest($urls,$options);
print_r($results);
?>
http://www.bkjia.com/phpjc/327533.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/327533.htmltecharticle如下所示: 复制代码 代码如下: ?php header('context-type:text/html;charset:gb2312;'); $urls = array( 'http://www.baidu.com/', 'http://www.pconline.com.cn/', 'http://www....