Chinaunix首页 | 论坛 | 博客
  • 博客访问: 177686
  • 博文数量: 36
  • 博客积分: 2078
  • 博客等级: 大尉
  • 技术积分: 330
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-09 17:13
文章分类

全部博文(36)

文章存档

2012年(1)

2011年(5)

2010年(9)

2009年(21)

我的朋友

分类:

2009-07-28 02:06:45

<?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);
    }
?>

晚上闲着没事干,弄几本小说放手机里看,上面是代码。

阅读(882) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2009-07-29 18:54:50

test