<?php /*配置数组*/ $arrayContent = array( 0=>40438, //小说id
1=>27128, //章节起始id
2=>27204, //章节结束id
3=>'浴火凤凰' //小说名字
); /*内容规则*/ $titlePre = "/(.*?)<\/h1>/"; //标题
$contentsPre = "/(.*?)<\/div>/" ; //内容 /*写内容*/ for( $i = $arrayContent[1 ]; $i<=$arrayContent[2 ]; $i++) { $url = "{$arrayContent[0]}_{$i}.html"; $cont = file_get_contents($url); preg_match_all($titlePre,$cont,$title); preg_match_all($contentsPre,$cont,$contents); $fh = fopen($arrayContent[3 ].".txt",'a+'); $writeContents = $title[1 ][0 ]."\r\n".str_replace('',"\r\n",str_replace('' ,' ',$contents[1 ][0 ]))."\r\n"; if( fwrite($fh,$writeContents) ) { echo "第{$i}页写入成功-"; } fclose($fh); }?>
|
晚上闲着没事干,弄几本小说放手机里看,上面是代码。
阅读(926) | 评论(1) | 转发(0) |