public CelebInfo Create(object oNode) { HtmlNode node = oNode as HtmlNode; if (node == null) { throw new Exception("Error; Are you sure that you are using the HtmlAgilityPack?"); } try { CelebInfo celeb = new CelebInfo() { Name = node.SelectSingleNode(ConfigUtil.IMDB_XPATH_CELEB_NAME).InnerText.Trim(), ImageUrl = node.SelectSingleNode(ConfigUtil.IMDB_XPATH_CELEB_IMAGEURL).Attributes["src"].Value, Role = node.SelectSingleNode(ConfigUtil.IMDB_XPATH_CELEB_ROLE).InnerText.Trim().Split("|", StringSplitOptions.RemoveEmptyEntries)[0].Trim(), }; celeb.Gender = ParseGedner(celeb.Role); celeb.BirthDate = GetBirthDateFromInnerWebCall(node); return(celeb); } catch (Exception ex) { _logger.LogError($"Couldnt create CelebInfo object. Bypassing.. Source HTML: {node?.OuterHtml} Exception: {ex} "); return(null); } }
public void Add(CelebInfo celeb) { this.Items.Add(celeb); }