If you want to read any ebook, go to Sina reading and search, and enter the corresponding parameters.
The Code is as follows:
/* Author: Yang Yu */
// You can search for any ebook on Sina first, and then enter the corresponding parameters.
// Http://vip.book.sina.com.cn/
// E-book Parameters
$ Array_book [0] = 38884; // novel id
$ Array_book [1] = 22172; // unit start id
$ Array_book [2] = 32533; // Chapter end id
$ Array_book [3] = 'survival record of special forces in China: Langya '; // novel name
// Match Parameters
$ Title_pre = "/(.*?) <\/H1>/"; // Title
$ Contents_pre = "/
(.*?) <\/P>/"; // content section
// Generate an e-book
For ($ I = $ array_book [1]; $ I <= $ array_book [2]; $ I ++ ){
$ Url = "http://vip.book.sina.com.cn/book/chapter_{$array_book1_01_1_1__1_i1_.html ";
$ Html = file_get_contents ($ url );
Preg_match_all ($ title_pre, $ html, $ title );
Preg_match_all ($ contents_pre, $ html, $ contents );
$ Fh = fopen($array_book%32.16.'.txt ', 'a + ');
$ Write_contents = $ title [1] [0]. "\ r \ n". str_replace ('
', "\ R \ n", str_replace ('
', '', $ Contents [1] [0])." \ r \ n ";
If (fwrite ($ fh, $ write_contents )){
Echo 'segment '. $ I.' Is crawled. </br> ';
}
Fclose ($ fh );
}