Beispiel #1
0
        public void can_get_rss_feed_from_page()
        {
            var document = new HtmlDocument();
            document.Load(GetType().Assembly.GetManifestResourceStream("Sketch.Test.sample-deviant-art-page.html"));

            var parser = new Scraper(document);
            var actual = parser.GetRssFeedUrl();

            Assert.AreEqual(RssFeedUrl, actual);
        }
Beispiel #2
0
        public void when_html_document_doesnt_contain_rss_feed()
        {
            var document = new HtmlDocument();
            document.CreateElement("html");

            var parser = new Scraper(document);
            var actual = parser.GetRssFeedUrl();

            Assert.IsNull(actual);
        }
Beispiel #3
0
 public void Start()
 {
     Trace.TraceInformation("Starting import of: " + Url);
     var scraper = new Scraper(Url);
     var rssFeedUrl = scraper.GetRssFeedUrl();
     if (rssFeedUrl != null)
     {
         var feed = new Feed(rssFeedUrl);
         foreach (var item in feed.Where(x => x.HasContent))
         {
             if (!_dao.Exists(uniqueId: item.Guid))
             {
                 var command = Mapper.Map<ImportStockPhoto>(item);
                 command.StockPhotoId = Guid.NewGuid();
                 _commandBus.Send(command);
             }
         }
     }
 }