コード例 #1
0
        /// <summary>
        /// Scrapes a document for schedule
        /// </summary>
        /// <param name="scheduleDocument">Schedule document to be scraped</param>
        /// <returns>Scraped ScheduleModel</returns>
        public async Task <Schedule.Week> ScrapeSchedule(IDocument scheduleDocument)
        {
            IHtmlCollection <IElement> matchupContainers = scheduleDocument.HtmlDocument.QuerySelectorAll(".schedules-list .schedules-table");

            Schedule.Week weekModel = new Schedule.Week();

            foreach (var matchupContainer in matchupContainers)
            {
                Regex           regex   = new Regex("(?:<!--).*(-->)");
                MatchCollection results = regex.Matches(matchupContainer.InnerHtml.ToString());
                foreach (var result in results)
                {
                    weekModel.RawElements.Add(result);
                    Console.WriteLine(result.ToString());
                }
            }

            weekModel.ScheduleDays = GetGameDays(weekModel.RawElements);

            foreach (Day scheduleDay in weekModel.ScheduleDays)
            {
                scheduleDay.Games = GetGames(scheduleDay);
            }

            return(weekModel);
        }
コード例 #2
0
        /// <summary>
        /// Scrapes the schedule for the given year and week
        /// </summary>
        /// <param name="scheduleDate">Schedule date from ScheduleDates dictionary</param>
        /// <param name="year">Schedule Year</param>
        /// <returns>Scraped SchedultModel</returns>
        public async Task <Schedule.Week> GetSchedule(string scheduleDate, int year)
        {
            Schedule.Week weekModel = new Schedule.Week();

            IDocument scheduleDoc = await LoadSchedule(scheduleDate, year);

            weekModel = await ScrapeSchedule(scheduleDoc);

            return(weekModel);
        }
コード例 #3
0
        /// <summary>
        /// Loads document for specified date
        /// </summary>
        /// <param name="scheduleDate">Schedule date from ScheduleDates dictionary</param>
        /// <param name="year">Schedule Year</param>
        /// <returns>Document cotaining schedule</returns>
        public async Task <IDocument> LoadSchedule(string scheduleDate, int year)
        {
            IDocument document = await _browser.NavigateAsync("http://www.nfl.com/schedules/" + year.ToString() + "/" + scheduleDate);

            return(document);
        }
コード例 #4
0
        /// <summary>
        /// Go to home page
        /// </summary>
        /// <returns>Home page document</returns>
        public async Task <IDocument> GoHome()
        {
            IDocument document = await _browser.NavigateAsync("https://www.nfl.com/");

            return(document);
        }