Exemplo n.º 1
0
        // 타자정보 얻어오기
        private List <HitterInfo> GetBatterInfos(String content)
        {
            List <HitterInfo> HitterInfos = new List <HitterInfo>();
            HtmlDocument      doc         = new HtmlDocument();

            doc.LoadHtml(content);
            var nodes = doc.DocumentNode.SelectSingleNode("//tbody").SelectNodes("tr");

            foreach (var node in nodes)
            {
                HtmlDocument hitterDoc = new HtmlDocument();
                hitterDoc.LoadHtml(node.OuterHtml);

                // Player ID 얻어오기
                String   href  = hitterDoc.DocumentNode.SelectSingleNode("//a").GetAttributeValue("href", "");
                String[] items = href.Split(separator, StringSplitOptions.RemoveEmptyEntries);

                HitterInfo htterInfo = new HitterInfo();
                htterInfo.HitterResults = new List <HitterResult>();
                htterInfo.PlayerId      = Convert.ToInt32(items[1]);

                // 결과 얻어오기
                var resultNodes = hitterDoc.DocumentNode.SelectNodes("//td");
                for (Int32 i = 1; i <= 12; ++i)
                {
                    String   result  = resultNodes[i].InnerHtml;
                    String[] results = result.Split(separatorSlush, StringSplitOptions.RemoveEmptyEntries);

                    foreach (String r in results)
                    {
                        if (String.IsNullOrEmpty(result) == false)
                        {
                            HitterResult hitterResult = new HitterResult();
                            hitterResult.Number = i;
                            hitterResult.Result = r.Trim();
                            htterInfo.HitterResults.Add(hitterResult);
                        }
                    }
                }
                HitterInfos.Add(htterInfo);
            }

            return(HitterInfos);
        }
Exemplo n.º 2
0
        // 타자정보 얻어오기
        private List<HitterInfo> GetBatterInfos(String content)
        {
            List<HitterInfo> HitterInfos = new List<HitterInfo>();
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(content);
            var nodes = doc.DocumentNode.SelectSingleNode("//tbody").SelectNodes("tr");

            foreach (var node in nodes)
            {
                HtmlDocument hitterDoc = new HtmlDocument();
                hitterDoc.LoadHtml(node.OuterHtml);

                // Player ID 얻어오기
                String href = hitterDoc.DocumentNode.SelectSingleNode("//a").GetAttributeValue("href", "");
                String[] items = href.Split(separator, StringSplitOptions.RemoveEmptyEntries);

                HitterInfo htterInfo = new HitterInfo();
                htterInfo.HitterResults = new List<HitterResult>();
                htterInfo.PlayerId = Convert.ToInt32(items[1]);

                // 결과 얻어오기
                var resultNodes = hitterDoc.DocumentNode.SelectNodes("//td");
                for(Int32 i = 1; i <= 12; ++i)
                {
                    String result = resultNodes[i].InnerHtml;
                    String[] results = result.Split(separatorSlush, StringSplitOptions.RemoveEmptyEntries);

                    foreach (String r in results)
                    {
                        if (String.IsNullOrEmpty(result) == false)
                        {
                            HitterResult hitterResult = new HitterResult();
                            hitterResult.Number = i;
                            hitterResult.Result = r.Trim();
                            htterInfo.HitterResults.Add(hitterResult);
                        }
                    }
                }
                HitterInfos.Add(htterInfo);
            }

            return HitterInfos;
        }