private void DownloadResources() { var resourceUrls = GetResourceUrls(); foreach (var resourceUrl in resourceUrls) { var url = GetFullResourceUrl(resourceUrl, absoluteUrl); if (WebResourceStorage.Current.Exists(url.ToString())) { continue; } try { WebResource resource = browser.DownloadWebResource(url); resources.Add(resource); if (!resource.ForceDownload || !string.IsNullOrEmpty(resource.LastModified)) { WebResourceStorage.Current.Save(resource); } } catch { } } }
private void RewriteHtml(WebResource resource, string fileName) { foreach (var resourceTag in resourceTags) { var nodes = html.Descendants(resourceTag.Key) .Where( e => e.Attributes.Any(a => a.Name == resourceTag.Value) && resource.AbsoluteUrl.ToString().EndsWith(e.Attributes[resourceTag.Value].Value)) .ToArray(); foreach (var node in nodes) { node.SetAttributeValue(resourceTag.Value, fileName); } } }