Copy Code code as follows:
* * Author:yang Yu <yangyu@sina.cn> *
Want to see what ebook, first go to Sina reading search, and then fill in the corresponding parameters can
http://vip.book.sina.com.cn/
ebook Parameters
$array _book[0] = 38884; Novel ID
$array _book[1] = 22172; Chapter Start ID
$array _book[2] = 32533; Chapter End ID
$array _book[3] = ' China Special Forces Survival record: Spike '; Novel name
Matching parameters
$title _pre = "/$contents _pre = "/<div id=\" conttxt\ "class=\" conttxt1\ "> (. *?) <\/div>/"; Content section
Generate E-books
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]. " \ r \ n ". Str_replace (' </p> '," \ r \ n '), Str_replace (' <p> ', ' ", $contents [1][0])." \ r \ n ";
if (fwrite ($fh, $write _contents)) {
Echo ' $i. ' The/br> is finished < ';
}
Fclose ($FH);
}