예제 #1
0
        private void btnDownloadSelected_Click(object sender, EventArgs e)
        {
            if (checkedList != null)
            {
                checkedList = null;
            }
            checkedList = new ArrayList();

            for (int i = 0; i < clbChapter.Items.Count; i++)
            {
                if (clbChapter.GetItemChecked(i) == true)
                {
                    checkedList.Add(i);
                }
            }

            string webContent;

            for (int i = 0; i < checkedList.Count; i++)
            {
                webContent = getContent(chapterURL + subURL[(int)checkedList[i]]);
                webContent = SimpTradChinese.ToTraditional(webContent);
                writeText(bookName + ".txt", webContent);
            }
            tbLog.Text = checkedList.Count + " Chapter Download OK";
        }
예제 #2
0
        public void buildBookChapter(string url)
        {
            string    content;
            int       index;
            WebClient client = new WebClient();

            client.Encoding = Encoding.GetEncoding("gb2312");
            string webStr = client.DownloadString(url);

            bookName = webStr.Substring(webStr.IndexOf("<title>") + 7);
            bookName = bookName.Substring(0, bookName.IndexOf("最新章节"));
            bookName = SimpTradChinese.ToTraditional(bookName);

            content = webStr;
            index   = content.IndexOf("<ul>");
            if (index == -1)
            {
                return;
            }
            content = content.Substring(index);

            index   = content.IndexOf("bottom");
            content = content.Substring(0, index);

            content = content.Replace("</ul>", "");
            content = content.Replace("<ul>", "");
            content = content.Replace("</li>", "");
            content = content.Replace("<li>", "");
            content = content.Replace("<a href=\"", "@");
            content = content.Replace("\">", "$");
            content = content.Replace("</a>", "%");
            index   = 0;
            int    head;
            int    tail;
            string chapterName;

            subURL = new ArrayList();
            while (content.IndexOf("@", index) != -1)
            {
                head  = content.IndexOf("@", index) + 1;
                index = head;
                tail  = content.IndexOf("$", index);
                subURL.Add(content.Substring(head, tail - head));

                head        = tail + 1;
                index       = head;
                tail        = content.IndexOf("%", index);
                index       = tail;
                chapterName = content.Substring(head, tail - head);
                chapterName = SimpTradChinese.ToTraditional(chapterName);
                clbChapter.Items.Add(chapterName);
            }
        }