Esempio n. 1
0
        private static void Search(string AddonName)
        {
            WebClient wc   = new WebClient();
            var       html = wc.DownloadString("https://wow.curseforge.com/search/get-results?providerIdent=projects&search=Bagnon");
            var       doc  = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(html);

            var nodes = doc.DocumentNode.SelectNodes("//*[contains(@class, 'results')]"); // This contains all the table rows and colums as part of the "results" class

            foreach (var node in nodes.Where(x => x.ChildNodes.Count >= 7))
            {
                Addon a        = new Addon();
                var   tempName = node.ChildNodes[3].InnerText.Replace("\r", "").Replace("\n", "").Trim();
                tempName        = tempName.Replace("  ", "^");
                a.Name          = tempName.Split('^')[0];
                a.Author        = node.ChildNodes[5].InnerText.Replace("\r", "").Replace("\n", "").Trim();
                a.LiveEpochDate = long.Parse(node.ChildNodes[7].ChildNodes[1].Attributes["data-epoch"].Value);
                //currentAddonsSearched.Add(a);
            }
        }
Esempio n. 2
0
        private static Addon UpdateAddonInfo(Addon inputAddon)
        {
            if (inputAddon.Name == "Lib: LibDFramework-1.0")
            {
                inputAddon.Name = "LibDFramework";
            }

            if (inputAddon.Name == "Deadly Boss Mods")
            {
                inputAddon.Name = "Deadly Boss Mods (DBM)";
            }

            var   addonNameToMatch = inputAddon.Name;
            Addon ret = new Addon();

            WebClient wc   = new WebClient();
            var       url  = "https://wow.curseforge.com/search/get-results?providerIdent=projects&search=" + HttpUtility.UrlEncode(inputAddon.Name);
            var       html = wc.DownloadString(url);
            var       doc  = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(html);

            var nodes = doc.DocumentNode.SelectNodes("//*[contains(@class, 'results')]"); // This contains all the table rows and colums as part of the "results" class

            if (nodes != null)
            {
                foreach (var node in nodes.Where(x => x.ChildNodes.Count >= 7))
                {
                    var tempName = node.ChildNodes[3].InnerText.Replace("\r", "").Replace("\n", "").Trim();
                    tempName        = tempName.Replace("  ", "^");
                    ret.Name        = tempName.Split('^')[0];
                    ret.Author      = node.ChildNodes[5].InnerText.Replace("\r", "").Replace("\n", "").Trim();
                    ret.DownloadURL = "https://wow.curseforge.com" + node.ChildNodes[3].ChildNodes[1].ChildNodes[1].OuterHtml.Replace("<a href=\"", "").Split('>')[0].Replace("\"", "");
                    // https://wow.curseforge.com/projects/bagnon?gameCategorySlug=addons&amp;projectID=1592
                    // https://wow.curseforge.com/projects/bagnon/files/latest

                    try
                    {
                        ret.LiveEpochDate = long.Parse(node.ChildNodes[7].ChildNodes[1].Attributes["data-epoch"].Value);
                    }
                    catch
                    {
                        ret.LiveEpochDate = 0;
                    }

                    if (ret.Name == addonNameToMatch)
                    {
                        return(ret);
                    }
                }
            }

            url  = "https://www.wowace.com/search/get-results?providerIdent=projects&search=" + HttpUtility.UrlEncode(inputAddon.Name);
            html = wc.DownloadString(url);
            doc  = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(html);

            nodes = doc.DocumentNode.SelectNodes("//*[contains(@class, 'results')]"); // This contains all the table rows and colums as part of the "results" class

            if (nodes == null)
            {
                return(inputAddon);
            }

            foreach (var node in nodes.Where(x => x.ChildNodes.Count >= 7))
            {
                var tempName = node.ChildNodes[3].InnerText.Replace("\r", "").Replace("\n", "").Trim();
                tempName        = tempName.Replace("  ", "^");
                ret.Name        = tempName.Split('^')[0];
                ret.Author      = node.ChildNodes[5].InnerText.Replace("\r", "").Replace("\n", "").Trim();
                ret.DownloadURL = "https://www.wowace.com" + node.ChildNodes[3].ChildNodes[1].ChildNodes[1].OuterHtml.Replace("<a href=\"", "").Split('>')[0].Replace("\"", "");

                try
                {
                    ret.LiveEpochDate = long.Parse(node.ChildNodes[7].ChildNodes[1].Attributes["data-epoch"].Value);
                }
                catch
                {
                    ret.LiveEpochDate = 0;
                }

                if (ret.Name == addonNameToMatch)
                {
                    return(ret);
                }
            }

            return(null);
        }