Esempio n. 1
0
        public async Task <PoePage> GetPoeWikiPage(string poeUrl)
        {
            using (WebClient wc = new WebClient())
            {
                Stream website = await wc.OpenReadTaskAsync(new Uri(poeUrl, UriKind.Absolute));

                using (StreamReader sr = new StreamReader(website))
                {
                    HtmlDocument poePage = new HtmlDocument();
                    poePage.LoadHtml(sr.ReadToEnd());

                    var itemBox = poePage.DocumentNode.SelectSingleNode("//span[contains(@class,'infobox-page-container')]");

                    if (itemBox != null)
                    {
                        return(GetPoeItemPage(itemBox));
                    }

                    var divCard = poePage.DocumentNode.SelectSingleNode("//div[contains(@class, 'item-box -divicard -floatright')]");
                    if (divCard != null)
                    {
                        return(PoePage.DivinationPage(divCard.OuterHtml));
                    }

                    var keystone = poePage.DocumentNode.SelectSingleNode("//div[contains(@class, 'infocard passive-keystone')]");
                    if (keystone != null)
                    {
                        return(PoePage.KeystonePage(keystone.OuterHtml));
                    }

                    return(PoePage.InvalidPage());
                }
            }
        }
Esempio n. 2
0
        public PoePage GetPoeItemPage(HtmlNode itemBox)
        {
            if (itemBox != null)
            {
                //Remove everything other than the first
                var totalChildren = itemBox.ChildNodes.Count;
                for (var i = 1; i < totalChildren; i++)
                {
                    itemBox.ChildNodes[1].Remove();
                }

                return(PoePage.ItemPage(itemBox.InnerHtml));
            }
            return(PoePage.InvalidPage());
        }