Пример #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);
        }