예제 #1
0
        public static void DoadloadComics()
        {
            Console.WriteLine("开始下载漫画:" + nameArr[nameIndex]);
            string name;
            string directory;
            bool   bl;
            int    num = 1;

            for (int i = 0; i < imageFrontUrlEn.Length; i++)
            {
                do
                {
                    name = num < 10 ? "000" + num + ".jpg" : "00" + num + ".jpg";
                    //Console.WriteLine(imageFrontUrlEn[i] + name);
                    directory = "comics\\" + nameArr[nameIndex] + "\\" + nameArrOne[i] /*+ "\\" + name*/;
                    if (num == 1)
                    {
                        Directory.CreateDirectory(directory);
                    }
                    Console.WriteLine(directory + "\\" + name);
                    bl = WebHelp.DownLoadImage(imageFrontUrlEn[i] + name,
                                               directory + "\\" + name);
                    Console.WriteLine(bl);
                    num++;
                } while (bl);

                num = 1;
            }
            Console.WriteLine("下载完成");
        }
예제 #2
0
        //待改进
        /// <summary>
        /// 获取图片url的/a/部分
        /// </summary>
        /// <param name="chapter">章节索引</param>
        /// <returns></returns>
        public static string CheckUrl(int chapter)
        {
            string          num1 = "";
            string          num2 = "";
            string          imageBaseUrl;
            string          url;
            string          check = "abcdefghijklmnopqrstuvwxyz1";
            int             num   = 0;
            MatchCollection mc    = Regex.Matches(urlArrOne[chapter], "kanmanhua/(\\d{1,10})/(\\d{1,10})[.]html");

            foreach (Match item in mc)
            {
                num1 = item.Groups[1].Value;
                num2 = item.Groups[2].Value;
            }
            if (int.Parse(num2) > 542724)
            {
                imageBaseUrl = imageBaseUrl5;
            }
            else if (int.Parse(num1) > 10000)
            {
                imageBaseUrl = imageBaseUrl6;
            }
            else
            {
                imageBaseUrl = imageBaseUrl7;
            }
            url = imageBaseUrl + "/" + check[num] + "/" + HttpUtility.UrlEncode(nameArr[nameIndex]).ToUpper() + "_" + num1 + "/"
                  + HttpUtility.UrlEncode(nameArrOne[chapter].Replace(" ", "")).ToUpper() + "_" + num2 + "/" + "0001.jpg";
            if (!WebHelp.DownLoadImage(url, "check.jpg"))
            {
                for (int i = 1; i < check.Length; i++)
                {//注意了
                    url = url.Replace("/" + check[i - 1] + "/", "/" + check[i] + "/");
                    num++;
                    //Console.WriteLine(url);
                    //Console.WriteLine(HttpUtility.UrlDecode(url));
                    if (WebHelp.DownLoadImage(url, "check.jpg"))
                    {
                        break;
                    }
                }
            }
            partOfUrl = "/" + check[num].ToString() + "/";
            return(partOfUrl);
        }
예제 #3
0
        /// <summary>
        /// 获取制定漫画的章节名和对应的url
        /// </summary>
        /// <param name="index">漫画索引</param>
        /// <returns>章节列表的长度</returns>
        public static int GetOneComics(int index)
        {
            string OneComicsUrl = baseUrl + urlArr[index];

            nameIndex = index;
            string page = WebHelp.GetHtmlPage(OneComicsUrl);
            //Console.WriteLine(page);
            //Console.ReadKey();
            string inStr1 = "class=\"new\"";
            string inStr2 = "class=\"blank_8\"";
            string nameRe = "title=\"([^\"]*)\"";
            string urlRe  = "href=\"([^\"]*)\"";

            //搞反了。。。
            //string nameRe = "href=\"(.{20,30}[.]html)\"";
            //string urlRe = "title=\"(.{0,40})\" target=";
            GetUrls(page, inStr1, inStr2, nameRe, urlRe, out nameArrOne, out urlArrOne);

            return(nameArrOne.Length);
        }