public void Download(FeedItem item) { item.Downloading = true; feedDownloader.Download( item.Url, Configuration.DownloadDirectory, (sender, e) => { item.Downloading = false; }, (sender, e) => { item.DownloadPercentage = e.ProgressPercentage; }); }
public async Task <List <string> > CreateUrls() { MetaDataConfiguration metaDataConfiguration = _configuration.MetaDataConfiguration; SymbolsConfiguration symbolsConfiguration = _configuration.SymbolsConfiguration; UrlsConfiguration urlsConfiguration = _configuration.UrlsConfiguration; HtmlDocument document = new HtmlDocument(); document.LoadHtml(await _feedDownloader.Download()); IEnumerable <HtmlNode> htmlNodes = document.DocumentNode.Descendants() .Where(x => x.Name == "td") .Where(x => x.HasClass("RNS_data")); List <string> urls = new List <string>(500); foreach (HtmlNode htmlNode in htmlNodes) { int startIndex = htmlNode.OuterHtml.IndexOf("/exchange/news/market-news", StringComparison.OrdinalIgnoreCase); if (startIndex != -1) { int endIndex = htmlNode.OuterHtml.IndexOf(metaDataConfiguration.Extension, startIndex, StringComparison.OrdinalIgnoreCase); if (endIndex != -1) { string value = htmlNode.OuterHtml.Substring(startIndex, (endIndex - startIndex) + metaDataConfiguration.Extension.Length); if (symbolsConfiguration.Symbols.Any(x => value.IndexOf(x, StringComparison.Ordinal) != -1)) { string url = urlsConfiguration.BaseUrl + value; urls.Add(url); } } } } return(urls); }