Copy code The code is as follows:
/* Author: Yang Yu
*/
// To find out what e-book you want to read, first go to Sina Reading to search, and then fill in the corresponding parameters
//http://vip.book.sina.com.cn/
//e-book parameters
$array_book[0] = 38884; //Novel id
$array_book[1] = 22172; //Chapter start id
$array_book[2] = 32533; //Chapter end id
$array_book [3] = 'Chinese Special Forces Survival Record: Langya'; //Novel name
//Matching parameters
$title_pre = "/(.*?)
$contents_pre = "/(.*?)
/"; //Content part
//Generate e-book
for( $i = $array_book[1]; $i <= $array_book[2]; $i++){
$url = "http://vip .book.sina.com.cn/book/chapter_{$array_book[0]}_{$i}.html";
$html = file_get_contents($url);
preg_match_all($title_pre,$html ,$title);
preg_match_all($contents_pre,$html,$contents);
$fh = fopen($array_book[3].'.txt','a+');
$write_contents = $title[1][0]."rn".str_replace('',"rn",str_replace('',' ',$contents[1][0])). "rn";
if( fwrite($fh,$write_contents) ){
echo 'Section '.$i.' has been fetched< /br>';
}
fclose ($fh);
}
http://www.bkjia.com/PHPjc/321104.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321104.htmlTechArticleCopy the code as follows: /* Author: Yang Yu yangyu@sina.cn */ //What electronics do you want to see? For books, first go to Sina Reading to search, and then fill in the corresponding parameters // http://vip.book.sina.com.cn...