Inheritance: IDisposable
Exemplo n.º 1
0
        private void LoadData()
        {
            nextResources.Clear();

            if (download.RemoteFileInfo.MimeType.IndexOf("text/html", StringComparison.OrdinalIgnoreCase) < 0)
            {
                return;
            }

            try
            {
                DownloadManager.Instance.OnBeginAddBatchDownloads();

                using (Stream htmlStream = File.OpenRead(download.LocalFile))
                {
                    using (HtmlParser parser = new HtmlParser(htmlStream))
                    {
                        AddUrls(parser.GetHrefs(context.BaseLocation), UrlType.Href);
                        AddUrls(parser.GetImages(context.BaseLocation), UrlType.Img);
                        AddUrls(parser.GetFrames(context.BaseLocation), UrlType.Frame);
                        AddUrls(parser.GetIFrames(context.BaseLocation), UrlType.IFrame);
                    }
                }
            }
            finally
            {
                DownloadManager.Instance.OnEndAddBatchDownloads();
            }
        }
Exemplo n.º 2
0
        private void FillListFromHtmlFile(List<ResourceLocation> urls)
        {
            using (Stream htmlStream = File.OpenRead(txtFileName.Text))
            {
                using (HtmlParser parser = new HtmlParser(htmlStream))
                {
                    IEnumerator<Uri> enumUri = parser.GetHrefs(this.location1.ResourceLocation.URL).GetEnumerator();

                    while (enumUri.MoveNext())
                    {
                        ResourceLocation newRl = location1.ResourceLocation;
                        newRl.URL = enumUri.Current.OriginalString;
                        urls.Add(newRl);
                    }
                }
            }
        }