Exemplo n.º 1
0
        public async Task GetsSomeHtml()
        {
            var downloader = new PageDownloadService();
            var html       = await downloader.GetHtmlAsync(new Uri("http://www.mattburkedev.com/"));

            Check.That(html).Contains("Matt Burke");
        }
Exemplo n.º 2
0
        public NewsArticleProvider_SingleRandomArticle_IntegrationTest(ITestOutputHelper output)
        {
            _output         = output;
            _extendedRandom = Substitute.For <IExtendedRandom>();
            var download = new PageDownloadService();

            var sites = new NewsSite[]
            {
                new EuroNewsSite(new EuroNewsSiteParser(), download, _extendedRandom),
                new VoxEuropaSite(new VoxEuropaSiteParser(), download, _extendedRandom),
            };

            _instance = new NewsArticleProvider(sites, _extendedRandom);
        }
Exemplo n.º 3
0
        // GET api/<controller>
        public async Task <PodcastMetadata> Get(string url)
        {
            if (LooksLikeMedia(url))
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new StringContent("Looks like a media file.")
                });
            }

            var downloader = new PageDownloadService();
            var html       = await downloader.GetHtmlAsync(new Uri(url));

            return(MetadataParser.LoadMetadata(html, url));
        }
Exemplo n.º 4
0
        private async Task <Dictionary <string, Article> > cacheArticles()
        {
            var download     = new PageDownloadService();
            var euroNewsSite = new EuroNewsSite(new EuroNewsSiteParser(), download, new ExtendedRandom());

            Dictionary <string, Article> cachedArticles = new Dictionary <string, Article>();

            foreach (Language language in pathsToArticles.Keys)
            {
                Console.WriteLine("Caching for language {0}", language);
                string[] urls = System.IO.File.ReadAllLines(pathsToArticles[language]);
                foreach (string url in urls)
                {
                    Console.WriteLine("Caching URL {0}", url);
                    Article article = await euroNewsSite.GetArticleAsync(url, language);

                    article.ActualLanguage = language;
                    cachedArticles.Add(url, article);
                }
            }
            return(cachedArticles);
        }