Exemplo n.º 1
0
        public IDictionary <string, string> ExpandSideBarMenu(WebPage page)
        {
            var sideBarMenu = page.Find(HtmlTags.Div.GetDescription(), By.Class(SIDE_BAR_MENU_CLASS)).FirstOrDefault();

            if (sideBarMenu is null)
            {
                return(ImmutableDictionary <string, string> .Empty);
            }

            var nodesMenu = sideBarMenu.OwnerDocument.DocumentNode.SelectNodes("//ul //a");
            var dic       = new Dictionary <string, string>();

            foreach (var node in nodesMenu)
            {
                var title = node.InnerText;
                var link  = node.Attributes.AttributesWithName(MENU_NODE_HREF_ATTRIBUTE).FirstOrDefault().Value;

                dic.TryAdd(title, link);
            }

            return(dic);
        }