private void GetNextWeekData(ref DfsData dfsData, string url) { GetNextWeekQbData(ref dfsData, url); GetNextWeekRbData(ref dfsData, url); GetNextWeekWrData(ref dfsData, url); GetNextWeekTeData(ref dfsData, url); GetNextWeekKData(ref dfsData, url); GetNextWeekDefData(ref dfsData, url); }
public DfsData Post(DFSScraperPackage package) { DfsData dfsData = new DfsData(); //if (dfsSite == "FanDuel") { GetNextWeekData(ref dfsData, FanDuelUrl); } //else if (dfsSite == "DraftKings") { GetNextWeekData(ref dfsData, DraftKingsUrl); } //else if (dfsSite == "FantasyAces") { GetNextWeekData(ref dfsData, FantasyAcesUrl); } //else if (dfsSite == "Draftpot") { GetNextWeekData(ref dfsData, DraftpotUrl); } //else if (dfsSite == "FantasyDraft") { GetNextWeekData(ref dfsData, FantasyDraftUrl); } //else if (dfsSite == "Yahoo") { GetNextWeekData(ref dfsData, YahooUrl); } if (package.DFSSite == "FanDuel") { GetNextWeekData(ref dfsData, OldFanDuelUrl); } else if (package.DFSSite == "DraftKings") { GetNextWeekData(ref dfsData, OldDraftKingsUrl); } else if (package.DFSSite == "FantasyAces") { GetNextWeekData(ref dfsData, OldFantasyAcesUrl); } else if (package.DFSSite == "Draftpot") { GetNextWeekData(ref dfsData, OldDraftpotUrl); } //else if (dfsSite == "FantasyDraft") { GetNextWeekData(ref dfsData, OldFantasyDraftUrl); } else if (package.DFSSite == "Yahoo") { GetNextWeekData(ref dfsData, OldYahooUrl); } dfsData.Quarterbacks.OrderByDescending(p => p.FantasyPoints); dfsData.RunningBacks.OrderByDescending(p => p.FantasyPoints); dfsData.WideReceivers.OrderByDescending(p => p.FantasyPoints); dfsData.TightEnds.OrderByDescending(p => p.FantasyPoints); dfsData.Kickers.OrderByDescending(p => p.FantasyPoints); dfsData.Defenses.OrderByDescending(p => p.FantasyPoints); return(dfsData); }
private void GetNextWeekQbData(ref DfsData dfsData, string url) { WebScraper scraper = new WebScraper(null, null, null); HtmlDocument document = scraper.Scrape(url + QbSuffix); //get projection-data table from html HtmlNode table = document.GetElementbyId(FantasyProsDataTable).Descendants().Where(t => t.Name == "tbody").FirstOrDefault <HtmlNode>(); //loop through rows in projection table List <HtmlNode> rows = table.SelectNodes("./tr").ToList <HtmlNode>(); if (rows.Count > 1) { foreach (HtmlNode row in rows) { //if player has cost per point for this week if (row.SelectSingleNode("./td[13]").InnerText.Length > 0) { //create new datarow Player player = new Player(); //parse name and team out of player cell FantasyProsParser parser = new FantasyProsParser(row.SelectSingleNode("./td[1]")); //set row values player.Id = dfsData.Quarterbacks.Count + 1; player.Name = parser.Name; player.Position = "QB"; player.NflTeam = parser.Team; player.FantasyPoints = decimal.Parse(row.SelectSingleNode("./td[11]").InnerText.Replace("pts", "")); player.Salary = int.Parse(row.SelectSingleNode("./td[12]").InnerText.Replace("$", "").Replace(",", "")); player.CostPerPoint = int.Parse(row.SelectSingleNode("./td[13]").InnerText.Replace("$", "")); //add datarow to datatable dfsData.Quarterbacks.Add(player); } } } }