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);
        }
Ejemplo n.º 2
0
        public static List <string> GetAllGridsFromForum(string iItemName, CookieCollection iLogCookies, MiqoItemPage iPage)
        {
            string           gridItemName = iItemName + " Grid";
            CookieCollection oCookies     = new CookieCollection();
            HttpStatusCode   oCode        = HttpStatusCode.NotFound;

            HtmlDocument answer = Service_Misc.GetWebPageFromRequest("GET " + iPage.URL + " 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/wp-login.php?redirect_to=https%3A%2F%2Fmiqobot.com%2Fforum%2Fforums%2Ftopic%2Fgrade-1-carbonized-matter-min-lv20%2F|Accept-Encoding: gzip, deflate, br|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|",
                                                                     iLogCookies, ref oCookies, ref oCode);

            if (null == answer)
            {
                return(null);
            }

            List <string>   attachmentsList        = new List <string>();
            List <HtmlNode> listAllAttachmentsNode = answer.DocumentNode.Descendants("div").ToList();

            foreach (HtmlNode node in listAllAttachmentsNode)
            {
                if (node.GetAttributeValue("class", "") == "bbp-attachments")
                {
                    attachmentsList.Add(Service_Misc.ExtractLink(node));
                }
            }

            List <string> listGrids = new List <string>();

            foreach (string attachmentLink in attachmentsList)
            {
                string gridRawContent = Service_Misc.GetContentFromRequest("GET " + attachmentLink + " HTTP/1.1|Host: miqobot.com|Connection: keep-alive|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/topic/grade-1-carbonized-matter-min-lv20/|Accept-Encoding: gzip, deflate, br|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|",
                                                                           iLogCookies, ref oCookies, ref oCode);

                string oGridName = "";
                try
                {
                    listGrids.Add(GetGridFromRawContent(iItemName, gridRawContent, out oGridName));
                }
                catch
                {
                }
            }
            return(listGrids);
        }
Ejemplo n.º 3
0
        public static string GetLastGrid(string iItemName, CookieCollection iLogCookies, MiqoItemPage iPage, out string oGridName)
        {
            string gridItemName = iItemName + " Grid";

            oGridName = "";
            CookieCollection oCookies = new CookieCollection();
            HttpStatusCode   oCode    = HttpStatusCode.NotFound;

            //Looking into cache directory
            DirectoryInfo exeDirectory   = new DirectoryInfo(Service_Misc.GetExecutionPath());
            DirectoryInfo cacheDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "CacheGrid"));

            if (!cacheDirectory.Exists)
            {
                cacheDirectory.Create();
            }

            string   gridRawContent = "";
            FileInfo cacheGridFile  = new FileInfo(Path.Combine(cacheDirectory.FullName, gridItemName + ".txt"));

            if (cacheGridFile.Exists)
            {
                oGridName      = gridItemName;
                gridRawContent = System.IO.File.ReadAllText(cacheGridFile.FullName);
            }
            else
            {
                HtmlDocument answer = Service_Misc.GetWebPageFromRequest("GET " + iPage.URL + " 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/wp-login.php?redirect_to=https%3A%2F%2Fmiqobot.com%2Fforum%2Fforums%2Ftopic%2Fgrade-1-carbonized-matter-min-lv20%2F|Accept-Encoding: gzip, deflate, br|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|",
                                                                         iLogCookies, ref oCookies, ref oCode);
                if (null == answer)
                {
                    return(null);
                }

                string          lastUrlAttachment      = "";
                List <HtmlNode> listAllAttachmentsNode = answer.DocumentNode.Descendants("div").ToList();
                foreach (HtmlNode node in listAllAttachmentsNode)
                {
                    if (node.GetAttributeValue("class", "") == "bbp-attachments")
                    {
                        lastUrlAttachment = Service_Misc.ExtractLink(node);
                    }
                }

                gridRawContent = Service_Misc.GetContentFromRequest("GET " + lastUrlAttachment + " HTTP/1.1|Host: miqobot.com|Connection: keep-alive|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/topic/grade-1-carbonized-matter-min-lv20/|Accept-Encoding: gzip, deflate, br|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|",
                                                                    iLogCookies, ref oCookies, ref oCode);
            }

            return(GetGridFromRawContent(iItemName, gridRawContent, out oGridName));
        }