static void Main(string[] args) { var down = new InternetDownloader.InternetDownloader( logger, "http://www.google.com", @"d:\", 1, InternetDownloaderOption.WithoutConstraints, new string[0]); try { down.DownloadContent(); } catch (InternetDownloaderException e) { logger.Error(e.Message); } Console.ReadKey(); }
private void GetRefs(HtmlAttributeCollection htmlAttributes) { var hrefAttr = htmlAttributes["href"]; if (hrefAttr != null) { var link = hrefAttr.Value; var path = RemoveParamsFromUrl(link); var extension = Path.GetExtension(path); if (extensionConstraints.Contains(extension)) { var fileSaver = new FileSaver(path, rootPath, rootFolder, protocol, logger); fileSaver.SaveSource(); return; } logger.Info("Link founded " + link); if (!link.StartsWith("http")) { if (link.StartsWith("//")) { link = protocol + link; } else { link = rootPath + link; } } var newLink = InternetDownloader.GetDirectoryName(link); if (level + 1 <= nestLevelLimit) { if (option == InternetDownloaderOption.WithinDomain && new Uri(link).Host != new Uri(rootPath).Host) { return; } hrefAttr.Value = Path.Combine(newLink, "index.html"); _links.Add(link); } } }