工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆

curl

function get_web_page$url ){    
    
$options = array(        
        
CURLOPT_RETURNTRANSFER => true,     // return web page        
        
CURLOPT_HEADER         => false,    // don't return headers        
        
CURLOPT_FOLLOWLOCATION => true,     // follow redirects        
        
CURLOPT_ENCODING       => "",       // handle all encodings        
        
CURLOPT_USERAGENT      => "spider"// who am i        
        
CURLOPT_AUTOREFERER    => true,     // set referer on redirect        
        
CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect        
        
CURLOPT_TIMEOUT        => 120,      // timeout on response        
        
CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects    
    
);    
    
$ch      curl_init$url );    
    
curl_setopt_array$ch$options );    
    
$content curl_exec$ch );    
    
$err     curl_errno$ch );    
    
$errmsg  curl_error$ch );    
    
$header  curl_getinfo$ch );    
    
curl_close$ch );    
    
$header['errno']   = $err;    
    
$header['errmsg']  = $errmsg;    
    
$header['content'] = $content;    
    return 
$header;
    }
?>

« 上一篇 | 下一篇 »

Trackbacks

点击获得Trackback地址,Encode: UTF-8

发表评论

评论内容 (必填):