Exemplo n.º 1
0
        public async Task Run(string url)
        {
            var htmlBody = await RequestManager.Request(url);

            if (htmlBody == null)
            {
                return;
            }
            var imageList = Regex.Matches(htmlBody, @"class=""fileThumb"" href=""(.*?)"" target");

            DownloadManager.InitDownload(imageList.Count);
            foreach (Match image in imageList)
            {
                var fileUrl  = "https:" + image.Groups[1].Value;
                var fileExt  = CrawlerManager.GetFileExt(fileUrl);
                var fileName = Regex.Match(fileUrl, @"http.*\/\/i\.4cdn\.org\/.*\/(.*)\.").Groups[1].Value;
                var filePath = UiManager.FolderBrowser.SelectedPath + "/" + fileName + fileExt;
                if (DownloadManager.IsFileAlreadyDownloaded(filePath))
                {
                    continue;
                }
                await DownloadManager.DownloadFile(fileUrl, filePath);

                DownloadManager.ChangeProgress();
            }
        }
Exemplo n.º 2
0
        public async Task Run(string url)
        {
            string htmlBody = await RequestManager.Request(url);

            if (string.IsNullOrEmpty(htmlBody))
            {
                return;
            }
            var imageList = Regex.Matches(htmlBody, @"<a class=""image"" href=""(.*?)"" target=""_blank""");

            DownloadManager.InitDownload(imageList.Count);

            foreach (Match image in imageList)
            {
                string fileUrl  = image.Groups[1].Value;
                string fileName = fileUrl.GetHashCode().ToString("X");
                string fileExt  = CrawlerManager.GetFileExt(fileUrl);
                string filePath = UiManager.FolderBrowser.SelectedPath + "\\" + fileName + fileExt;
                await DownloadManager.DownloadFile(fileUrl, filePath);

                DownloadManager.ChangeProgress();
            }
        }