去年的时候有位发了份原码,我放邮箱里,后来有事.今年打开邮箱正好那份源码没法下载下来了!
哪个有源码或讲讲原理啊!

解决方案 »

  1.   

    找到小说网址
    请求获取HTML代码
    分析HTML代码获取所有小说的URL地址
    在请求
    正则处理
    保存数据库
      

  2.   

    呵呵 就是webclient得到他的内容 然后通过正则分析出内容和链接 然后继续获取呗。这玩意儿我都做了好几个了。
    贴点代码给你参考一下
    System.Net.WebClient cli = new System.Net.WebClient();
                Uri u = new Uri(Settings1.Default.Uri);
                int i = Settings1.Default.Uri.LastIndexOf('/');
                string sSite = Settings1.Default.Uri.Substring(0, i + 1);
                string sPage = Settings1.Default.Uri.Substring(i + 1);
                byte[] buff=cli.DownloadData(u);
                Encoding enc = Encoding.GetEncoding(Settings1.Default.Encode);
                
                Regex r = new Regex(Settings1.Default.NextReg, RegexOptions.IgnoreCase);
                Regex r2 = new Regex(Settings1.Default.TextBeg, RegexOptions.IgnoreCase);
                
                string sContent = enc.GetString(buff);
                while (true) {
                    
                    string sText = "";
                    i = sContent.IndexOf(Settings1.Default.TextBeg);
                    if (i > 0) {
                        int j = sContent.IndexOf(Settings1.Default.TextEnd, i + 1);
                        if (j > 0) {
                            sText = sContent.Substring(i + Settings1.Default.TextBeg.Length, j - i - Settings1.Default.TextBeg.Length - 1);
                           // sText = sText.Replace("<br />", "\r\n");
                           // sText = sText.Replace("&nbsp;", " ");
                        }
                    }
                    
                    string sNextPage="";
                    Match m = r.Match(sContent);
                    if (m.Success)
                    {
                        sNextPage = m.Result("$1");
                        WritePage(sPage, sNextPage, sText);
                    }
                    else {
                        WritePage(sPage, sNextPage, sText);
                        break;
                    }
                    sPage = sNextPage;
                    u = new Uri(sSite + sPage);
                    buff = cli.DownloadData(u);
                    sContent = enc.GetString(buff);
                    m = r.Match(sContent);
                }
      

  3.   

    private void WritePage(string sPage, string sNextPage, string sText) {
                sPage = sPage.Replace(".asp", ".html");
                sNextPage = sNextPage.Replace(".asp", ".html");
                FileStream fs = new FileStream(Settings1.Default.LocalPath + sPage, FileMode.Create);
                StreamWriter s = new StreamWriter(fs);
                
                s.Write("<html><head><title>javascript using Array</title></head><body>");
                //s.Write("<pre>");
                s.Write(sText);
                //s.Write("</pre>");
                s.Write("<a id='anext' href='" + sNextPage + "' target='_self'>nextpage</a>");
                s.Write("</body></html>");
                s.Close();
                fs.Close();
            }