Home  >  Article  >  Backend Development  >  PHP download page

PHP download page

WBOY
WBOYOriginal
2016-08-08 09:31:271701browse

/*
author:whq
Function: Get the content of the webpage
*/
include "../Snoopy/Snoopy.class.php";
class CuteCrawler
{
/*
Download web pages through fopen
*/
public function getContentByFopen($url)
{
$f = fopen($url, 'r');
$content = '';
if($f)
{
while(($buffer = fgets($f, 10240)) != false)
{
$content = $content. $buffer;
}
fclose($f);
}
return $content;
}
public function getContentByFilegetcontent($url)
{
$content = file_get_contents($url);
return $content;
}
          /*
                                                    use CURL
            through using ’’’’’ out’s out’s ’’ out’s out’s out’s out’s out’s out out out out outole out Througholeole outolece outoleps out out right out outole out out out out out out out out out out out out out out outCl {
                $ch = curl_init($url) ;                  curl_setopt($ch, CURLOPT_HEADER, 0);       curl_close($ch);                                                      return $content; getContentSnoopy($url)
               {
                                                                                                                                                                                t;results;
} }


}

$ url = "http://www.kugou.com/yy/special/single/18920.html";
$crawler = new CuteCrawler();
$content = $crawler->getContentByFopen($url);
$ con1 = $crawler->getContentByFilegetcontent($url); $con2 = $crawler->getContentByCurl($url); $con3 = $crawler->getContentSnoopy($url);
//echo 'content: '.$content; // echo $con1; // var_dump($con1);
print_r($con3);?> The above introduces the PHP download webpage, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn