Beispiel #1
0
        /// <summary>
        /// Creates the snapshot
        /// </summary>
        /// <param name="url">The url to crawl</param>
        /// <returns>true if the snapshot was successfully created</returns>
        public async Task <string> Get(string url, string userAgent)
        {
            HttpClient client = new HttpClient();

            CrawlerConfig config = new CrawlerConfig()
            {
                ApiId          = ConfigurationManager.AppSettings["CrawlerServiceApiId"],
                Application    = ConfigurationManager.AppSettings["CrawlerServiceApplication"],
                ExpirationDate = DateTime.UtcNow.AddDays(3),
                Store          = true,
                Url            = url,
                UserAgent      = userAgent
            };

            var response = await client.PostAsJsonAsync <CrawlerConfig>(ConfigurationManager.AppSettings["CrawlerServiceEndPoint"], config);

            response.EnsureSuccessStatusCode();

            var result = response.Content.ReadAsStringAsync().Result;

            if (DurandalViewNotFound(result))
            {
                throw new HttpException(404, "Durandal view not found");
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the snapshot
        /// </summary>
        /// <param name="url">The url to crawl</param>
        /// <returns>true if the snapshot was successfully created</returns>
        public async Task<string> Get(string url, string userAgent)
        {
            HttpClient client = new HttpClient();
            
            CrawlerConfig config = new CrawlerConfig() 
            {
                ApiId = ConfigurationManager.AppSettings["CrawlerServiceApiId"],
                Application = ConfigurationManager.AppSettings["CrawlerServiceApplication"],
                ExpirationDate = DateTime.UtcNow.AddDays(3),
                Store = true,
                Url = url,
                UserAgent = userAgent
            };

            var response = await client.PostAsJsonAsync<CrawlerConfig>(ConfigurationManager.AppSettings["CrawlerServiceEndPoint"], config);

            response.EnsureSuccessStatusCode();

            var result = response.Content.ReadAsStringAsync().Result;

            if (DurandalViewNotFound(result))
            {
                throw new HttpException(404, "Durandal view not found");
            }

            return result;
        }