By referring to other people's ideas and turning them into your own, you will find that over time you will have ideas and methods to temporarily solve many problems.
/*
Function: Get page content, Store and read; lost63
*/
Class GetUrl{
var $url; //Address
var $result; //Result
var $content; //Content
var $list; //List
function GetUrl($url){
$this->url=$url;
$this->GetContent();
$this->GetList ();
$this->FileSave();
//print_r($this->list[2]);
}
private function GetContent(){
$ this->result=fopen($this->url,"r");
while(!feof($this->result)){
$this->content.=fgets( $this->result,9999);
}
}
private function GetList(){
preg_match_all('/
(.*?)/',$this->content,$this->list);
$this->list[2]=array_unique($this-> ;list[2]); //Remove the same values
while(list($key,$value)=each($this->list[2])){
if(strpos($ value,".html")==0||strpos($value,"jiaocheng")==0){
unset($this->list[2][$key]);
} else{
$this->list[2][$key]=substr($value,0,strpos($value,".html")).".html"; //Remove unnecessary tags
}
}
}
private function FileSave(){
foreach($this->list[2] as $value){
$this->url= $value; //Reassign value
$this->content=null;
$this->GetContent(); //Extract content
preg_match_all('/
(.*? )/',$this->content,$files); //Get the title
$filename=$files[1][0].".html"; //Storage name
$content=$this->str_cut($this->content,'http://pagead2.googlesyndication.com/pagead/show_ads.js','
');
$file=fopen($filename,"w");
fwrite($file,$content);
fclose($file);
echo $filename."Save OK
n";
}
}
function str_cut($str ,$start, $end) {
$content = strstr( $str, $start );
$content = substr( $content, strlen( $start ), strpos( $content, $end ) - strlen( $start ) );
return $content;
}
}
$w=new GetUrl(" http://www.ijavascript.cn/jiaocheng/javascript-jiaocheng-352.html");
?>
http://www.bkjia.com/PHPjc/321035.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321035.htmlTechArticleRefer to other people’s ideas and turn them into your own. You will find that after you slow down, you will have temporary solutions to many problems. ideas and methods. Copy the code The code is as follows: ?php /* Function: Get the page...