/*
author:whq
作用:取得網頁的內容
*/
include "../Snoopy/Snoopy.class.php"; *
透過fopen來下載網頁
*/
public function getContentByFopen($url)
{
$content = '';
if($f)
{
while(($buffer = fgets($f, 10240)) != false)
. buffer;
}
fclose($f);
}
return $content;
}B.
$content = file_get_contents($url);
return $content;
} /* ByCurl($url)
{ $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0);
$content = curl_exec($ch); curl_close($ch); return $content; ($url)
{
$snoopy = new Snoopy;
$oop y->results; }
}
$url = " http://www.kugou.com/yy/special/single/18920.html"; $crawler = new CuteCrawler(); $content = $crawler->getContentByF($url); ->getContentByFilegetcontent($url);
$con2 = $crawler->getContentByCurl($url);
$con3 我 / echo $con1;
// var_dump($con1);
print_r($con3);
?>
以上就介紹了PHP下載網頁,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。