用PHP如何采集网站首页的标题和内容

2024-11-20 11:46:51
推荐回答(1个)
回答1:

[php]function get_contents($url){
                $ch = curl_init();     
                curl_setopt ($ch, CURLOPT_URL, $url);     
                curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt ($ch, CURLOPT_TIMEOUT, 1000); 
                $file_contents = curl_exec($ch);     
                curl_close($ch);
                return $file_contents;
}
$url="http://play.kankan.xunlei.com/?hallid=2959";
$con=get_contents($url);
$con=str_replace("\"../","\"http://kankan.xunlei.com/",$con);
echo $con;
?>[/php]