Пример #1
0
        public Situation_W Parse(Schedule schedule, String html)
        {
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(html);
            var element = doc.DocumentNode.SelectSingleNode("//*[@class=\"situation\"]");

            Situation_W situation_W = new Situation_W();
            situation_W.GameId = schedule.GameId;
            situation_W.Content = element.OuterHtml;
            return situation_W;
        }
Пример #2
0
        public BoxScore_W Parse(Schedule schedule, String html)
        {
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(html);
            var elements = doc.DocumentNode.SelectNodes("//table[@summary='타자기록']");

            BoxScore_W boxScore_W = new BoxScore_W();
            boxScore_W.GameId = schedule.GameId;
            boxScore_W.AwayHitter = elements[0].OuterHtml;
            boxScore_W.HomeHitter = elements[1].OuterHtml;

            elements = doc.DocumentNode.SelectNodes("//table[@summary='투수기록']");
            boxScore_W.AwayPitcher = elements[0].OuterHtml;
            boxScore_W.HomePitcher = elements[1].OuterHtml;

            return boxScore_W;
        }
Пример #3
0
 private BoxScore_W GetBoxScore_W(Crawler.Manager mgr, Schedule schedule, Int32 lastCount)
 {
     if (lastCount == 0)
     {
         throw new Exception(String.Format("경기상황 얻어오기 실패, 게임아이디 {0}", schedule.GameId));
     }
     try
     {
         var boxScore_W = mgr.GetBoxScore_W(schedule);
         return boxScore_W;
     }
     catch
     {
         return GetBoxScore_W(mgr, schedule, lastCount - 1);
     }
 }
Пример #4
0
        // Schedule_W에서 Schedule로 변환
        private Schedule ConvertToSchedule(Schedule_W schedule_W)
        {
            Schedule schedule = new Schedule
            {
                Year = schedule_W.Year,
                Month = schedule_W.Month,
                Day = schedule_W.Day,
                BallPark = schedule_W.BallPark,
                Etc = schedule_W.Etc
            };

            schedule.Hour = Convert.ToInt32(schedule_W.Time.Substring(0, 2));
            schedule.Minute = Convert.ToInt32(schedule_W.Time.Substring(3, 2));

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(schedule_W.Play);
            var nodes = doc.DocumentNode.SelectNodes("span");

            schedule.AwayTeam = Util.Util.GetTeamInitialFromName(nodes[0].InnerHtml);
            schedule.HomeTeam = Util.Util.GetTeamInitialFromName(nodes[1].InnerHtml);

            if (schedule_W.Etc == "-")
            {
                // 경기가 진행되었으면
                nodes = doc.DocumentNode.SelectNodes("em/span");
                schedule.AwayTeamScore = Convert.ToInt32(nodes[0].InnerHtml);
                schedule.HomeTeamScore = Convert.ToInt32(nodes[2].InnerHtml);

                doc.LoadHtml(schedule_W.Relay);
                schedule.Href = doc.DocumentNode.SelectSingleNode("a").GetAttributeValue("href", "");

                try
                {
                    schedule.GameId = schedule.Href.Split(new char[] { '&', '=' })[5];
                    schedule.LeagueId = Convert.ToInt32(schedule.Href.Split(new char[] { '&', '=' })[1]);
                    schedule.SeriesId = Convert.ToInt32(schedule.Href.Split(new char[] { '&', '=' })[3]);
                }
                catch (Exception)
                {
                    return null;
                }

            }
            return schedule;
        }
Пример #5
0
 public void Init(Schedule schedule)
 {
     itemSchedule = schedule;
 }
Пример #6
0
        // 경기상황 정보 얻기
        public Situation_W GetSituation_W(Schedule schedule)
        {
            InitCromeDriver();
            CrawlerSituation crawler = new CrawlerSituation(chromeDriver);
            crawler.Init(schedule);
            String html = crawler.GetHTML();
            return Parser.ParserSituation_W.Instance.Parse(schedule, html);

        }
Пример #7
0
        // 박스스코어 정보 얻기
        public BoxScore_W GetBoxScore_W(Schedule schedule)
        {
            InitCromeDriver();
            CrawlerBoxScore crawler = new CrawlerBoxScore(chromeDriver);
            crawler.Init(schedule);
            String html = crawler.GetHTML();
            return Parser.ParserBoxScore_W.Instance.Parse(schedule, html);

        }