Ejemplo n.º 1
0
        public static List <MiqoItemPage> GetURLItem(string iItemName, CookieCollection iLogCookies, HtmlDocument iDocument)
        {
            List <MiqoItemPage> result = new List <MiqoItemPage>();

            CookieCollection oCookies = new CookieCollection();
            HttpStatusCode   oCode    = HttpStatusCode.NotFound;
            HtmlDocument     answer   = iDocument;

            if (null == answer)
            {
                answer = Service_Misc.GetWebPageFromRequest("GET https://miqobot.com/forum/forums/topic/index-gathering-grids/ HTTP/1.1|Host: miqobot.com|Connection: keep-alive|Cache-Control: max-age=0|Upgrade-Insecure-Requests: 1|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Sec-Fetch-Mode: navigate|Sec-Fetch-User: ?1|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3|Sec-Fetch-Site: same-origin|Referer: https://miqobot.com/forum/forums/forum/grids-and-presets/|Accept-Encoding: gzip, deflate, br|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|Cookie: wordpress_test_cookie=WP+Cookie+check; _ga=GA1.2.1771485810.1566089776||",
                                                            iLogCookies, ref oCookies, ref oCode);
            }
            if (null == answer)
            {
                return(result);
            }

            HtmlNode firstAnswerNode = Service_Misc.GetChildNodeByID(answer.DocumentNode, "d4p-bbp-quote-1116");

            if (null == firstAnswerNode)
            {
                return(new List <MiqoItemPage>());
            }

            List <HtmlNode> listItemNodes = firstAnswerNode.Descendants("li").ToList();


            foreach (HtmlNode node in listItemNodes)
            {
                if (null == node)
                {
                    continue;
                }

                string nodeInnerTextLower = node.InnerText.ToLower();
                if (nodeInnerTextLower.Contains("by") && nodeInnerTextLower.Contains(iItemName.ToLower()))
                {
                    //Found node !

                    List <HtmlNode> listLinks = node.Descendants("a").ToList();
                    foreach (HtmlNode link in listLinks)
                    {
                        MiqoItemPage itempage = new MiqoItemPage();
                        itempage.URL         = link.GetAttributeValue("href", "");
                        itempage.Contributor = link.InnerText;
                        result.Add(itempage);
                    }
                }
            }

            return(result);
        }