Beispiel #1
0
        public void DownloadAPage(string resolution, string outputFolder, int page)
        {
            var webClient     = new WebClient();
            var filenameGroup = new Regex("/([^/]*)$", RegexOptions.Compiled);
            var source        = new InterfaceLiftSource()
            {
                Resolution = resolution
            };
            var pageCount = source.GetPageCount();

            if (page <= pageCount)
            {
                var resourceUris = source.GetResourceUris(page);
                foreach (var resourceUri in resourceUris)
                {
                    var fileName = filenameGroup.Match(resourceUri).Groups[1].Value;
                    var path     = Path.Combine(outputFolder, fileName);
                    if (!ShouldDownload(path))
                    {
                        if (!WebClientExtensions.TryDownloadFile(webClient, resourceUri, path, 2))
                        {
                            log.Error("Error when downloading " + resourceUri);
                        }
                    }
                }
            }
        }
        public string GetPage(int pageNumber)
        {
            var webClient     = new WebClient();
            var pageUriFormat = "http://interfacelift.com/wallpaper_beta/downloads/date/any/index{0}.html?promo=disabled";
            var pageUri       = String.Format(pageUriFormat, pageNumber.ToString());

            return(WebClientExtensions.TryDownloadString(webClient, pageUri, 1));
        }