By referring to the ideas of others, you will find that you have the ideas and methods to solve many problems on a temporary basis.
Copy CodeThe code is as follows:
/*
Function: Get the content of the page, store it and read it; Lost63
*/
Class geturl{
var $url; Address
var $result; Results
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 ('/(. *?) <\/a>/', $this->content, $this->list);
$this->list[2]=array_unique ($this->list[2]); Remove the same value
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 unwanted labels
}
}
}
Private Function FileSave () {
foreach ($this->list[2] as $value) {
$this->url= $value; Re-assign Value
$this->content=null;
$this->getcontent (); Extract Content
Preg_match_all ('/ <title>(.*?) <\/title>/', $this->content, $files); Take title</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.html www.bkjia.com true http://www.bkjia.com/PHPjc/321035.html techarticle by referring to the ideas of others, you will find that you have the ideas and methods to solve many problems on a temporary basis. Copy the code as follows:? PHP/* Feature: Get page ...