/// <summary>
        /// Get album's page
        /// </summary>
        /// <returns>Parsed album's page</returns>
        public AlbumResult GetFullAlbum()
        {
            WebDownloader downloader = new WebDownloader(AlbumUrl);
            string        content    = downloader.DownloadData();

            return(WebContentParser.Parse <AlbumResult>(content));
        }
        /// <summary>
        /// Get album's page async
        /// </summary>
        /// <returns>Parsed album's page</returns>
        public async Task <AlbumResult> GetFullAlbumAsync()
        {
            WebDownloader downloader = new WebDownloader(AlbumUrl);
            string        content    = await downloader.DownloadDataAsync();

            return(WebContentParser.Parse <AlbumResult>(content));
        }
Esempio n. 3
0
        /// <summary>
        /// Get band's page
        /// </summary>
        /// <returns>Parsed band's page</returns>
        public BandResult GetFullBand()
        {
            WebDownloader downloader = new WebDownloader(BandUrl);
            string        content    = downloader.DownloadData();

            return(WebContentParser.Parse <BandResult>(content));
        }
Esempio n. 4
0
        /// <summary>
        /// Get band's page async
        /// </summary>
        /// <returns>Parsed band's page</returns>
        public async Task <BandResult> GetFullBandAsync()
        {
            WebDownloader downloader = new WebDownloader(BandUrl);
            string        content    = await downloader.DownloadDataAsync();

            return(WebContentParser.Parse <BandResult>(content));
        }
Esempio n. 5
0
        public object GetValue(HtmlNode rootNode, out bool canParse)
        {
            if (!PropertyType.GetInterfaces().Contains(typeof(IEnumerable)) || !PropertyType.IsGenericType)
            {
                throw new Exception("Property have to be a generic ienumerable");
            }

            canParse = true;

            if (!string.IsNullOrEmpty(Selector))
            {
                rootNode = rootNode.QuerySelector(Selector);

                if (rootNode == null)
                {
                    if (!SkipIfNotFound)
                    {
                        throw new ElementNotFoundException(Selector);
                    }

                    canParse = false;
                }
            }

            Type itemType = PropertyType.GetGenericArguments()[0];

            return(CastIenumerableToGeneric(WebContentParser.ParseList(itemType, rootNode.InnerHtml), itemType));
        }
Esempio n. 6
0
        /// <summary>
        /// Gets list of band's albums simple list async
        /// </summary>
        public async Task <IEnumerable <AlbumBandResult> > GetAlbumsAsync(AlbumListType type)
        {
            WebDownloader wd      = new WebDownloader($@"https://www.metal-archives.com/band/discography/id/{Id}/tab/" + type.ToString().ToLower());
            string        content = await wd.DownloadDataAsync();

            return(WebContentParser.ParseList <AlbumBandResult>(content));
        }
Esempio n. 7
0
        public IEnumerable <Item> CollectItems(string url)
        {
            var websiteRequest = Task.Run(() => GetWebsiteContent(url));
            var content        = websiteRequest.Result;
            var items          = WebContentParser.ParseList <Item>(content);

            return(items);
        }
Esempio n. 8
0
        public void WebsiteParserModelGeneric()
        {
            string html = WebsiteParser.Tests.Properties.Resources.SongContent;

            var result = WebContentParser.Parse <AlbumModel>(html);

            Assert.AreEqual(8, result.Songs.Count());
        }
Esempio n. 9
0
        public void WebsiteParserModel()
        {
            string html = WebsiteParser.Tests.Properties.Resources.SongContent;

            AlbumModel result = (AlbumModel)WebContentParser.Parse(typeof(AlbumModel), html);

            Assert.AreEqual(8, result.Songs.Count());
        }
Esempio n. 10
0
        public void WebsiteParserList()
        {
            string html = WebsiteParser.Tests.Properties.Resources.SongContent;

            var result = WebContentParser.ParseList(typeof(SongModel), html);

            Assert.AreEqual(8, result.Cast <SongModel>().Count());
        }
Esempio n. 11
0
        private IEnumerable <SongResult> GetSongs(string resource)
        {
            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(resource);

            string songsHolder = document.QuerySelector(".table_lyrics").InnerHtml;

            return(WebContentParser.ParseList <SongResult>(songsHolder));
        }
Esempio n. 12
0
        private Metadata GetMetadata(string resource)
        {
            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(resource);

            string html = document.DocumentNode.QuerySelector("#auditTrail").InnerHtml;

            return(WebContentParser.Parse <Metadata>(html));
        }
Esempio n. 13
0
        public object GetValue(HtmlNode rootNode, out bool canParse)
        {
            canParse = true;

            if (!string.IsNullOrEmpty(Selector))
            {
                rootNode = rootNode.QuerySelector(Selector);

                if (rootNode == null)
                {
                    if (!SkipIfNotFound)
                    {
                        throw new ElementNotFoundException(Selector);
                    }

                    canParse = false;
                }
            }

            return(WebContentParser.Parse(PropertyType, rootNode.InnerHtml));
        }
Esempio n. 14
0
 private BandResult GetBand(string resource)
 {
     return(WebContentParser.Parse <BandResult>(resource));
 }
Esempio n. 15
0
 private AlbumResult GetAlbum(string resource)
 {
     return(WebContentParser.Parse <AlbumResult>(resource));
 }
Esempio n. 16
0
 private IEnumerable <AlbumBandResult> GetThreeRows(string resource)
 {
     return(WebContentParser.ParseList <AlbumBandResult>(resource).Take(3));
 }