Copyright statement: original works can be reproduced. During reprinting, you must mark the original publication, author information, and this statement in hyperlink form. Otherwise, legal liability will be held. Http://blog.csdn.net/mayongzhan-ma yongzhan, myz, mayongzhan
I remember there was a post-collection process.
This is its upgraded version.
Reprocess the connection and merge a TXT book.
<? PHP
/**
* @ Name collection book. php
* @ Date sun Mar 01 22:48:02 CST 2009
* @ Copyright Ma yongzhan (myz)
* @ Author ma yongzhan (myz)
* @ Link http://blog.csdn.net/mayongzhan/
*/
// Header ('content-type: text/html; charset = utf8 ');
Header ('content-type: text/html; charset = gb2312 ');
Error_reporting (e_all );
Date_default_timezone_set ('Asia/Shanghai ');
Set_time_limit (0 );
Function writer ($ content, $ URL)
{
$ Fp = fopen ($ URL, 'AB ');
Fwrite ($ FP, $ content );
Fclose ($ FP );
}
$ Folder = '2'; // folder
$ Book_base_url = 'xxxxxxxxxxxxxxxxxxxxxxxxxx ';
$ Book_url = 'yyyyyyyyyyy.html ';
$ Main = file_get_contents ($ book_base_url. $ book_url );
Preg_match_all ('/Chapter _.*? /. Html/', $ main, $ pages );
$ Pages = array_unique ($ pages [0]);
Foreach ($ pages as $ value ){
Writer (file_get_contents ($ book_base_url. $ value), './'. $ folder. '/'.20.value.'.txt ');
$ STR = file_get_contents ('./'. $ folder. '/'.20.value.'.txt ');
// Print_r ($ Str );
Preg_match ("/(// Print_r ($ ARR); Die ();
$ Arr [6] = preg_replace ("/(<span [^>] +> .*? <A [^>] +> )(.*?) (</A> </span>)/s "," $2 ", preg_replace ("/<p> | </P> /", "/R/N", $ arr [6]);
$ Result = "/R/N records/R/n ----------------------------------------------/R/N records/R/n ----------------". $ arr [2]. "/R/N records/R/n ----------------------------------------------/R/n ------------------------------------------------/R/N ". $ arr [6];
Writer ($ result, './'. $ folder. '/new.txt ');
}
?>