php curl抓取函数,可抓跳转页

字体大小: 中小 标准 ->行高大小: 标准
<?php 
function cmg($url, $data = '', $timeout = 30, $header = 0, $follow = 1) { 
$ch = curl_init(); 
$options = array( 
CURLOPT_URL => $url, 
CURLOPT_TIMEOUT => $timeout, 
CURLOPT_HEADER => $header, 
CURLOPT_RETURNTRANSFER => 1, 
CURLOPT_FOLLOWLOCATION => $follow, 
); 
if($data) { 
$options[CURLOPT_POST] = 1; 
$options[CURLOPT_POSTFIELDS] = $data; 
} 
curl_setopt_array($ch, $options); 
$result = $header ? curl_getinfo($ch) : curl_exec($ch); 
curl_close($ch); 
return $result; 
} 
?>

此文章由 www.phpgz.com 收集整理 ,地址为: http://www.phpgz.com/htmls/67209.html

大屏阅读,大屏评论.