示例#1
0
        /// <summary>
        /// Download the given uri and then extracts its title.
        /// </summary>
        public async Task <string> GetUrlTitleAsync(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException(nameof(uri));
            }

            var result = await _downloaderService.DownloadPageAsync(uri.ToString());

            return(GetHtmlPageTitle(result.Data));
        }
示例#2
0
        public async Task <IActionResult> DownloadFile()
        {
            var url    = Url.Action(nameof(Index), typeof(DownloaderServiceController).ControllerName(), null, Request.Scheme);
            var result = await _downloaderService.DownloadPageAsync(url,
                                                                    new AutoRetriesPolicy
            {
                MaxRequestAutoRetries = 2,
                AutoRetriesDelay      = TimeSpan.FromSeconds(3)
            });

            return(Content(result.Data));
        }
示例#3
0
        /// <summary>
        /// Download the given uri and then extracts its title.
        /// </summary>
        public async Task <string> GetUrlTitleAsync(Uri uri)
        {
            var result = await _downloaderService.DownloadPageAsync(uri.ToString());

            return(GetHtmlPageTitle(result.Data));
        }