- 论坛徽章:
- 0
|
?php
/*配置数组*/
$arrayContent = array(
0=>40438, //小说id
1=>27128, //章节起始id
2=>27204, //章节结束id
3=>'浴火凤凰' //小说名字
);
/*内容规则*/
$titlePre = "/(.*?)/"; //标题
$contentsPre = "/(.*?)/"; //内容
/*写内容*/
for( $i = $arrayContent[1]; $i=$arrayContent[2]; $i++)
{
$url = "http://vip.book.sina.com.cn/book/chapter_{$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);
}
?>
晚上闲着没事干,弄几本小说放手机里看,上面是代码。
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/94441/showart_2009897.html |
|