Ejemplo n.º 1
0
        public static void ProBuilds(string cname)
        {
            BuildData.BuildsList = new List<BuildData.BuildInfo>();
            WebClient pbClient = new WebClient();
            String Data = null;
            try
            {
                Data = pbClient.DownloadString("http://lolbuilder.net/" + cname);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            String SkillSeq = ExtractString(Data, "window.skillOrder[0] = [", "];");
            string[] seqinstringarray = SkillSeq.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            int[] OrderedSequence = new int[seqinstringarray.Length];
            for (int i = 0; i < seqinstringarray.Length; i++)
            {
                try
                {
                    OrderedSequence[i] = int.Parse(seqinstringarray[i]);
                    Console.Write(OrderedSequence[i]);
                }
                catch (Exception e)
                {
                    Console.Write(e);
                }

                BuildData.SkillSequence = OrderedSequence;
            }
            MatchCollection Builds = Regex.Matches(Data, "<div class=\"build-body\"[\\S\\s]*?id=\"build-content-");
            foreach (var b in Builds)
            {
                List<String> Starting = new List<string>();
                List<String> Buildorders = new List<string>();
                List<String> Final = new List<string>();
                List<String> BuildSummary = new List<string>();
                BuildData.BuildInfo BuildInfo = new BuildData.BuildInfo();

                //Specific Build info
                string buildinfo = b.ToString();

                //Extraction
                String sitemsect = ExtractString(buildinfo, "<div class=\"shortcut-area starting-item-sets row",
                    "</section>");
                MatchCollection StartItems = Regex.Matches(sitemsect, "<small class=\"t-overflow[\\S\\s]*?</small>");
                foreach (var si in StartItems)
                {
                    String ItemNameFixed = HTMLStrip(si.ToString());
                    Starting.Add(ItemNameFixed);

                }
                String BOItemsect = ExtractString(buildinfo, "<h4 class=\"block-title\">Build Order", "</section>");
                MatchCollection BuildOrder = Regex.Matches(BOItemsect, "<small class=\"t-overflow\">[\\S\\s]*?</small>");
                foreach (var item in BuildOrder)
                {
                    String ItemNameFixed = HTMLStrip(item.ToString());
                    Buildorders.Add(ItemNameFixed);

                }
                String FinalItemsect = ExtractString(buildinfo, "<section class=\"final-items\">", "</section>");
                MatchCollection FinalBuild = Regex.Matches(FinalItemsect,
                    "<small class=\"t-overflow\">[\\S\\s]*?</small>");
                foreach (var item in FinalBuild)
                {
                    String ItemNameFixed = HTMLStrip(item.ToString());
                    Final.Add(ItemNameFixed);
                    //Console.WriteLine(ItemNameFixed);
                }

                String BuildSummarysect = ExtractString(buildinfo, "<div class=\"shortcut-area build-summary\">", "</section>");
                MatchCollection Summary = Regex.Matches(BuildSummarysect,
                    "<small class=\"t-overflow\">[\\S\\s]*?</small>");
                foreach (var item in Summary)
                {
                    String ItemNameFixed = HTMLStrip(item.ToString());
                    BuildSummary.Add(ItemNameFixed);
                }

                // Add to Lists
                BuildInfo.startingitems = Starting;
                BuildInfo.buildorder = Buildorders;
                BuildInfo.finalitems = Final;
                BuildInfo.buildsummary = BuildSummary;
                BuildData.BuildsList.Add(BuildInfo);
            }
        }
Ejemplo n.º 2
0
        public static void ProBuilds(string cname)
        {
            BuildData.BuildsList = new List <BuildData.BuildInfo>();
            WebClient pbClient = new WebClient();
            String    Data     = null;

            try
            {
                Data = pbClient.DownloadString("http://lolbuilder.net/" + cname);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            String SkillSeq = ExtractString(Data, "window.skillOrder[0] = [", "];");

            string[] seqinstringarray = SkillSeq.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            int[]    OrderedSequence  = new int[seqinstringarray.Length];
            for (int i = 0; i < seqinstringarray.Length; i++)
            {
                try
                {
                    OrderedSequence[i] = int.Parse(seqinstringarray[i]);
                    Console.Write(OrderedSequence[i]);
                }
                catch (Exception e)
                {
                    Console.Write(e);
                }

                BuildData.SkillSequence = OrderedSequence;
            }
            MatchCollection Builds = Regex.Matches(Data, "<div class=\"build-body\"[\\S\\s]*?id=\"build-content-");

            foreach (var b in Builds)
            {
                List <String>       Starting     = new List <string>();
                List <String>       Buildorders  = new List <string>();
                List <String>       Final        = new List <string>();
                List <String>       BuildSummary = new List <string>();
                BuildData.BuildInfo BuildInfo    = new BuildData.BuildInfo();

                //Specific Build info
                string buildinfo = b.ToString();

                //Extraction
                String sitemsect = ExtractString(buildinfo, "<div class=\"shortcut-area starting-item-sets row",
                                                 "</section>");
                MatchCollection StartItems = Regex.Matches(sitemsect, "<small class=\"t-overflow[\\S\\s]*?</small>");
                foreach (var si in StartItems)
                {
                    String ItemNameFixed = HTMLStrip(si.ToString());
                    Starting.Add(ItemNameFixed);
                }
                String          BOItemsect = ExtractString(buildinfo, "<h4 class=\"block-title\">Build Order", "</section>");
                MatchCollection BuildOrder = Regex.Matches(BOItemsect, "<small class=\"t-overflow\">[\\S\\s]*?</small>");
                foreach (var item in BuildOrder)
                {
                    String ItemNameFixed = HTMLStrip(item.ToString());
                    Buildorders.Add(ItemNameFixed);
                }
                String          FinalItemsect = ExtractString(buildinfo, "<section class=\"final-items\">", "</section>");
                MatchCollection FinalBuild    = Regex.Matches(FinalItemsect,
                                                              "<small class=\"t-overflow\">[\\S\\s]*?</small>");
                foreach (var item in FinalBuild)
                {
                    String ItemNameFixed = HTMLStrip(item.ToString());
                    Final.Add(ItemNameFixed);
                    //Console.WriteLine(ItemNameFixed);
                }

                String          BuildSummarysect = ExtractString(buildinfo, "<div class=\"shortcut-area build-summary\">", "</section>");
                MatchCollection Summary          = Regex.Matches(BuildSummarysect,
                                                                 "<small class=\"t-overflow\">[\\S\\s]*?</small>");
                foreach (var item in Summary)
                {
                    String ItemNameFixed = HTMLStrip(item.ToString());
                    BuildSummary.Add(ItemNameFixed);
                }


                // Add to Lists
                BuildInfo.startingitems = Starting;
                BuildInfo.buildorder    = Buildorders;
                BuildInfo.finalitems    = Final;
                BuildInfo.buildsummary  = BuildSummary;
                BuildData.BuildsList.Add(BuildInfo);
            }
        }