public void InsertMatchinfoDev(Matches match, int sportid) { try { using (SqlConnection objConn = new SqlConnection(OddsConnection.GetConnectionString())) { SqlParameter[] arrParam = { new SqlParameter("@MatchDate", match.date), new SqlParameter("@Time", match.time), new SqlParameter("@Home", match.home) , new SqlParameter("@Draw",match.draw), new SqlParameter("@Away",match.away), new SqlParameter("@BettingLink",match.bettinglink) , new SqlParameter("@CreatedDate",match.createddate), new SqlParameter("@DisplayEndDateTime",match.Displayenddatetime),new SqlParameter("@sportid",sportid), new SqlParameter("@leagueid",Convert.ToInt32(match.league)),new SqlParameter("@ResultLink",match.resultlink) }; SqlCommand cmd = new SqlCommand("sp_InsertMatchinfoDev", objConn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddRange(arrParam); cmd.CommandTimeout = 500; objConn.Open(); cmd.ExecuteNonQuery(); objConn.Close(); } } catch(Exception ex) { ErrorLog(ex.ToString()); } }
public string CrawlGolfTurnament(string url, string sportid) { try { TraceService("Crawling Started: Golf:0 ,SportID:" + sportid + " , URL:" + url + "\n"); string html = Helper.GetWebSiteContent(url); DataSet ds = new DataSet(); HtmlAgilityPack.HtmlDocument doc = Helper.LoadHtml(html); CrawlFirstPageData crawldata = new CrawlFirstPageData(); Matches match = new Matches(); XmlDocument xmldoc = new XmlDocument(); List<GolfTurnament> turnamentlist = new List<GolfTurnament>(); var row11 = doc.DocumentNode.SelectSingleNode("//div[@class='containerHeight']"); var row = row11.SelectNodes(".//a[@class='stats_link']"); var rows = row11.SelectNodes("//div[@class='stats']"); if (rows != null) { string enddatetime = String.Empty; for (int ii = 0; ii < rows.Count; ii = ii + 0) { GolfTurnament golf = new GolfTurnament(); int i = ii; try { var n = rows[ii].ParentNode; if (n.Name == "a") { if (n == null) golf.Link = ""; else golf.Link = "http://wikiform.com.au/oddschecker/" + n.Attributes["href"].Value; } else golf.Link = ""; if (rows[ii].Attributes["style"].Value == "clear:both;width:100px;") { golf.Duration = rows[ii].InnerText.Trim(); ii += 1; } else golf.Duration = ""; if (rows[ii].Attributes["style"].Value == "width:317px;text-decoration:underline;" || rows[ii].Attributes["style"].Value == "width:317px;") { golf.Turnament = rows[ii].InnerText.Trim(); ii += 1; } else golf.Turnament = ""; if (rows[ii].Attributes["style"].Value == "width:242px;") { golf.Course = rows[ii].InnerText.Trim(); ii += 1; } else golf.Course = ""; if (rows[ii].Attributes["style"].Value == "width:122px;border-right:0;") { golf.Champion = rows[ii].InnerText.Trim(); ii += 1; } else golf.Champion = ""; InsertGoldTurnament(golf); } catch (Exception ex) { } if (i == ii) ii += 1; turnamentlist.Add(golf); } xmldoc = GenerateXmlGolfTurnament(turnamentlist); // InsertGoldTurnament(xmldoc, sportid); TraceService("Data Inserted: Golf:0 ,SportID:" + sportid + " , URL:" + url + "\n"); } //ds = crawldata.NewRecords(xmldoc); //return ds; return "Command completed successfully"; } catch (Exception ex) { TraceService("Error:0 ,SportID:" + sportid + " , URL:" + url + "\n"); return ex.Message; } }
public void CrawlChampionLeauge(string id,string link, string time) { try { // added file parameter for ftp(file) (GET,POST), remove it for http (GET,POST) string html = Helper.GetWebSiteContent(link); DataSet ds = new DataSet(); HtmlAgilityPack.HtmlDocument doc = Helper.LoadHtml(html); CrawlFirstPageData crawldata = new CrawlFirstPageData(); Matches match = new Matches(); MatchResult mr = new MatchResult(); XmlDocument xmldoc = new XmlDocument(); string[] result = new string[17]; var list = doc.DocumentNode.SelectSingleNode("//div[@id='betting_stats']//div"); result[0] = id; var nodes = list.SelectNodes("//tr"); result[2] = list.SelectSingleNode("//div[@id='ht_score']").InnerText.Trim(); result[1] = list.SelectSingleNode("//span[@class='score']").InnerText.Trim(); result[3] = list.SelectSingleNode("//div[@id='first_gs']").InnerText.Trim(); result[4] = list.SelectSingleNode("//div[@id='last_gs']").InnerText.Trim(); result[5] = result[3].Substring(result[3].IndexOf("mins")-3,2)+""; result[6] = result[4].Substring(result[4].IndexOf("mins") - 3, 2) + ""; result[7] = ""; result[8] = list.SelectSingleNode("//div[@id='first_hgs']").InnerText.Trim(); result[9] = list.SelectSingleNode("//div[@id='last_hgs']").InnerText.Trim(); result[10] = list.SelectSingleNode("//div[@id='first_ags']").InnerText.Trim(); result[11] = list.SelectSingleNode("//div[@id='last_ags']").InnerText.Trim(); result[12] = list.SelectSingleNode("//div[@id='first_booking']").InnerText.Trim(); result[13] = list.SelectSingleNode("//div[@id='last_booking']").InnerText.Trim(); result[14] = list.SelectSingleNode("//div[@id='total_yellow']").InnerText.Trim(); result[15] = list.SelectSingleNode("//div[@id='total_red']").InnerText.Trim(); result[16] = list.SelectSingleNode("//div[@id='bookings_index']").InnerText.Trim(); // Get Update Market(Match) Result MatchResult(result,id); crawldata.InsertChampionResult(result); } catch (Exception ex) { //return ex.Message; } }
public void CrawlLeagues(string section,string url,List<Leagues> leaguelist) { TraceService("Crawling Started:----League------ Section:"+section+" URL: "+url+" -"); try { string html = Helper.GetWebSiteContent(url); DataSet ds = new DataSet(); HtmlAgilityPack.HtmlDocument doc = Helper.LoadHtml(html); CrawlFirstPageData crawldata = new CrawlFirstPageData(); Matches match = new Matches(); XmlDocument xmldoc = new XmlDocument(); var list = doc.DocumentNode.SelectSingleNode("//ul[@id='sport-nav']//ul"); int check = 0; var sectionnodes = list.SelectNodes(".//li[@class='level-4 nav-content-item more-li first']"); if (sectionnodes != null) { for (int x = 0; x < sectionnodes.Count; x++) { if (sectionnodes[x].InnerText.Trim().Contains(section)) { if (sectionnodes[x].InnerText.Trim().Substring(0, section.Length).Equals(section)) { var nodes = sectionnodes[x].SelectNodes(".//a"); if (nodes != null) { for (int i = 0; i < nodes.Count; i++) { string league = nodes[i].InnerText; string link = "http://www.oddschecker.com" + nodes[i].Attributes["href"].Value; leaguelist.Add(new Leagues() { League = league, Link = link, Section = section }); } } } } } } } catch (Exception ex) { TraceService("Error:----League------ Section:" + section + " URL: " + url + " - "+ex.ToString()); } }
//public string CrawlMyPage(string url,int sportid,long leagueid) //{ // try // { // TraceService("Crawling Started: League ID:" + leagueid + " ,SportID:" + sportid + " , URL:" + url + "\n"); // System.IO.StreamReader rader; // string shtml = Helper.GetWebSiteContent(url); // // shtml = shtml.Replace("<!doctype HTML>", ""); // DataSet ds = new DataSet(); // // HtmlAgilityPack.HtmlDocument doc = Helper.LoadHtml(html); // CrawlFirstPageData crawldata = new CrawlFirstPageData(); // Matches match = new Matches(); // HtmlDocument doc = Helper.LoadHtml(shtml); // TextReader tr = new StringReader(shtml); // //xmldoc.Load(tr); // XmlDocument xmldoc = new XmlDocument(); // List<Matches> matchlist = new List<Matches>(); // var row11 =doc.DocumentNode.SelectSingleNode("//div[@id='fixtures']"); // string title = row11.SelectNodes(".//h2")[0].InnerText; // var rows = row11.SelectNodes("//table//tr"); // if (rows != null) // { // string enddatetime = String.Empty; // for (int ii = 1; ii < rows.Count; ii = ii + 1) // { // var dr = rows[ii].InnerText.Trim(); // var cols = rows[ii].SelectNodes("./td[@class='day']"); // if (cols != null) // { // string t = cols[0].InnerText.Trim(); // match.date = t; // string[] matchdate = t.Split(' '); // enddatetime = matchdate[1].Substring(0, (matchdate[1].Length - 2)) + " " + matchdate[2].Substring(0, 3) + " " + matchdate[3]; // enddatetime = DateTime.Parse(enddatetime).ToString("yyyy-MM-dd"); // } // else // { // var colnew = rows[ii].SelectNodes("./td"); // if (colnew != null && colnew.Count > 4) // { // match.time = colnew[0].InnerText.Trim(); // var Dlink = colnew[4].InnerText.Trim(); // var home = colnew[1].SelectNodes(".//span[@class='fixtures-bet-name']"); // var draw = colnew[2].SelectNodes(".//span[@class='fixtures-bet-name']"); // var away = colnew[3].SelectNodes(".//span[@class='fixtures-bet-name']"); // match.home = home[0].InnerText.Trim(); // match.draw = draw[0].InnerText.Trim(); // match.away = away[0].InnerText.Trim(); // match.createddate = DateTime.Now; // //var link = colnew[4].SelectNodes("./a[contains(@href, '/gaelic-games/gaelic-football/')]"); // var link = colnew[4].SelectNodes("./a"); // match.bettinglink = "http://www.oddschecker.com/" + link[0].Attributes["href"].Value.Replace("/winner", "/betting-markets"); // match.resultlink = "http://www.oddschecker.com/" + link[0].Attributes["href"].Value.Replace("/winner", "/winner"); // match.Displayenddatetime = DateTime.Parse(enddatetime + " " + match.time); // match.league = leagueid.ToString(); // //match.bettinglink = "http://www.oddschecker.com/"+link[0].Attributes["href"].Value; // matchlist.Add(new Matches() { date = match.date, time = match.time, home = match.home, draw = match.draw, away = match.away, bettinglink = match.bettinglink, Displayenddatetime = match.Displayenddatetime,resultlink=match.resultlink }); // crawldata.InsertMatchinfoDev(match,sportid); // } // } // } // xmldoc = GenerateXml(matchlist); // // crawldata.InsertMatchInfo(xmldoc,sportid,leagueid); // TraceService("Data Inserted: League ID:" + leagueid + " ,SportID:" + sportid + " , URL:" + url + "\n"); // } // //ds = crawldata.NewRecords(xmldoc); // //return ds; // return "Command completed successfully"; // } // catch (Exception ex) // { // TraceService("Error:" + leagueid + " ,SportID:" + sportid + " , URL:" + url + "\n"); // return ex.Message; // } //} public void CrawlLeagues(object threadparam) { ThreadParameters p = threadparam as ThreadParameters; string url = p.URL; try { TraceService("Crawling Started: --------Lague--------SportID: Footbal , URL:" + url + "\n"); string html = Helper.GetWebSiteContent(url); DataSet ds = new DataSet(); HtmlAgilityPack.HtmlDocument doc = Helper.LoadHtml(html); CrawlFirstPageData crawldata = new CrawlFirstPageData(); Matches match = new Matches(); XmlDocument xmldoc = new XmlDocument(); List<Leagues> leaguelist = new List<Leagues>(); var list = doc.DocumentNode.SelectSingleNode("//ul[@id='sport-nav']//ul"); int check = 0; var nodes = list.SelectNodes("./li"); if (nodes != null) { for (int i = 0; i < nodes.Count; i++) { //if (check > 0) //{ // var node = nodes[i].SelectNodes("./a"); // if (node != null) // { // string league = node[0].InnerText; // string link = "http://www.oddschecker.com" + node[0].Attributes["href"].Value; // leaguelist.Add(new Leagues() { League = league, Link = link }); // } //} //if (nodes[i].InnerText.Trim().Equals("All Events")) //{ // //i=nodes.GetNodeIndex(nodes[i]); // check++; //} if (nodes[i].InnerText.Trim().Contains("English")) { if (nodes[i].InnerText.Trim().Substring(0, 7).Equals("English")) { var node = nodes[i].SelectNodes(".//a"); if (node != null) { for (int j = 0; j < node.Count; j++) { string league = node[j].InnerText; string link = "http://www.oddschecker.com" + node[j].Attributes["href"].Value; leaguelist.Add(new Leagues() { League = league, Link = link, Section = "English" }); } } } } if (nodes[i].InnerText.Trim().Contains("Scottish")) { if (nodes[i].InnerText.Trim().Substring(0, 8).Equals("Scottish")) { var node = nodes[i].SelectNodes(".//a"); if (node != null) { for (int j = 0; j < node.Count; j++) { string league = node[j].InnerText; string link = "http://www.oddschecker.com" + node[j].Attributes["href"].Value; leaguelist.Add(new Leagues() { League = league, Link = link, Section = "Scottish" }); } } } } if (nodes[i].InnerText.Trim().Contains("European")) { if (nodes[i].InnerText.Trim().Substring(0, 8).Equals("European")) { var node = nodes[i].SelectNodes(".//a"); if (node != null) { for (int j = 0; j < node.Count; j++) { string league = node[j].InnerText; string link = "http://www.oddschecker.com" + node[j].Attributes["href"].Value; leaguelist.Add(new Leagues() { League = league, Link = link, Section = "European" }); } } } } if (nodes[i].InnerText.Trim().Contains("Champions League")) { if (nodes[i].InnerText.Trim().Substring(0, 16).Equals("Champions League")) { var node = nodes[i].SelectNodes(".//a"); if (node != null) { for (int j = 0; j < node.Count; j++) { string league = node[j].InnerText; string link = "http://www.oddschecker.com" + node[j].Attributes["href"].Value; leaguelist.Add(new Leagues() { League = league, Link = link, Section = "Champions League" }); } } } } if (nodes[i].InnerText.Trim().Contains("Europa League")) { if (nodes[i].InnerText.Trim().Substring(0, 13).Equals("Europa League")) { var node = nodes[i].SelectNodes(".//a"); if (node != null) { for (int j = 0; j < node.Count; j++) { string league = node[j].InnerText; string link = "http://www.oddschecker.com" + node[j].Attributes["href"].Value; leaguelist.Add(new Leagues() { League = league, Link = link, Section = "Europa League" }); } } } } } xmldoc = GenerateXmlForLeagues(leaguelist); crawldata.InsertLeagues(xmldoc); TraceService("Data Inserted : --------Lague--------SportID: Footbal , URL:" + url + "\n"); } } catch (Exception ex) { TraceService("Error : --------Lague--------SportID: Footbal , URL:" + url + "\n"); //return ex.Message; } }
public void CrawlMyPage(Object tp) { ThreadParameters dev = new ThreadParameters(); dev = tp as ThreadParameters; string url = dev.URL; int sportid = dev.SportID; long leagueid = dev.LeagueID; try { TraceService("Crawling Started: League ID:" + leagueid + " ,SportID:" + sportid + " , URL:" + url + "\n"); System.IO.StreamReader rader; string shtml = Helper.GetWebSiteContent(url); // shtml = shtml.Replace("<!doctype HTML>", ""); DataSet ds = new DataSet(); // HtmlAgilityPack.HtmlDocument doc = Helper.LoadHtml(html); CrawlFirstPageData crawldata = new CrawlFirstPageData(); Matches match = new Matches(); HtmlDocument doc = Helper.LoadHtml(shtml); TextReader tr = new StringReader(shtml); //xmldoc.Load(tr); XmlDocument xmldoc = new XmlDocument(); List<Matches> matchlist = new List<Matches>(); var row11 = doc.DocumentNode.SelectSingleNode("//div[@id='fixtures']"); string title = row11.SelectNodes(".//h2")[0].InnerText; var rows = row11.SelectNodes("//table//tr"); if (rows != null) { string enddatetime = String.Empty; for (int ii = 1; ii < rows.Count; ii = ii + 1) { var dr = rows[ii].InnerText.Trim(); var cols = rows[ii].SelectNodes("./td[@class='day']"); if (cols != null) { string t = cols[0].InnerText.Trim(); match.date = t; string[] matchdate = t.Split(' '); enddatetime = matchdate[1].Substring(0, (matchdate[1].Length - 2)) + " " + matchdate[2].Substring(0, 3) + " " + matchdate[3]; enddatetime = DateTime.Parse(enddatetime).ToString("yyyy-MM-dd"); } else { var colnew = rows[ii].SelectNodes("./td"); if (colnew != null && colnew.Count > 4) { match.time = colnew[0].InnerText.Trim(); var Dlink = colnew[4].InnerText.Trim(); var home = colnew[1].SelectNodes(".//span[@class='fixtures-bet-name']"); var draw = colnew[2].SelectNodes(".//span[@class='fixtures-bet-name']"); var away = colnew[3].SelectNodes(".//span[@class='fixtures-bet-name']"); match.home = home[0].InnerText.Trim(); match.draw = draw[0].InnerText.Trim(); match.away = away[0].InnerText.Trim(); match.createddate = DateTime.Now; //var link = colnew[4].SelectNodes("./a[contains(@href, '/gaelic-games/gaelic-football/')]"); var link = colnew[4].SelectNodes("./a"); match.bettinglink = "http://www.oddschecker.com/" + link[0].Attributes["href"].Value.Replace("/winner", "/betting-markets"); match.resultlink = "http://www.oddschecker.com/" + link[0].Attributes["href"].Value.Replace("/winner", "/winner"); match.Displayenddatetime = DateTime.Parse(enddatetime + " " + match.time); match.league = leagueid.ToString(); //match.bettinglink = "http://www.oddschecker.com/"+link[0].Attributes["href"].Value; matchlist.Add(new Matches() { date = match.date, time = match.time, home = match.home, draw = match.draw, away = match.away, bettinglink = match.bettinglink, Displayenddatetime = match.Displayenddatetime, resultlink = match.resultlink }); crawldata.InsertMatchinfoDev(match, sportid); } } } xmldoc = GenerateXml(matchlist); // crawldata.InsertMatchInfo(xmldoc,sportid,leagueid); TraceService("Data Inserted: League ID:" + leagueid + " ,SportID:" + sportid + " , URL:" + url + "\n"); } //ds = crawldata.NewRecords(xmldoc); //return ds; // return "Command completed successfully"; } catch (Exception ex) { TraceService("Error:" + leagueid + " ,SportID:" + sportid + " , URL:" + url + "\n"); // return ex.Message; } }
public string CrawlMyPage(string html) { try { DataSet ds = new DataSet(); HtmlAgilityPack.HtmlDocument doc = Helper.LoadHtml(html); CrawlFirstPageData crawldata = new CrawlFirstPageData(); Matches match = new Matches(); XmlDocument xmldoc = new XmlDocument(); List<Matches> matchlist = new List<Matches>(); var row11 = doc.DocumentNode.SelectSingleNode("//div[@id='fixtures']"); string title = row11.SelectNodes(".//h2")[0].InnerText; var rows = row11.SelectNodes("//table//tr"); if (rows != null) { string enddatetime = String.Empty; for (int ii = 1; ii < rows.Count; ii = ii + 1) { var dr = rows[ii].InnerText.Trim(); var cols = rows[ii].SelectNodes("./td[@class='day']"); if (cols != null) { string t = cols[0].InnerText.Trim(); match.date = t; string[] matchdate = t.Split(' '); enddatetime = matchdate[1].Substring(0, 2) + " " + matchdate[2].Substring(0, 3) + " " + matchdate[3]; enddatetime = DateTime.Parse(enddatetime).ToString("yyyy-MM-dd"); } else { var colnew = rows[ii].SelectNodes("./td"); if (colnew != null && colnew.Count>4) { match.time = colnew[0].InnerText.Trim(); var Dlink = colnew[4].InnerText.Trim(); var spn = colnew[1].SelectNodes(".//span[@class='fixtures-bet-name']"); string Place = spn[0].InnerText.Trim(); var odds = colnew[1].SelectNodes(".//span[@class='odds']"); string Od = odds[0].InnerText.Trim(); match.home = Place +" "+ Od; match.draw = colnew[2].InnerText.Trim(); match.away = colnew[3].InnerText.Trim(); var link = colnew[4].SelectNodes("./a[contains(@href, '/gaelic-games/gaelic-football/')]"); match.bettinglink = "http://www.oddschecker.com/" + link[0].Attributes["href"].Value.Replace("/winner", "/betting-markets"); match.Displayenddatetime = DateTime.Parse(enddatetime +"T"+ match.time); match.resultlink = "http://www.oddschecker.com/" + link[0].Attributes["href"].Value.Replace("/winner", ""); //match.bettinglink = "http://www.oddschecker.com/"+link[0].Attributes["href"].Value; matchlist.Add(new Matches() { date = match.date,time=match.time, home = match.home.Substring(0,match.home.IndexOf("(")).Trim(), draw = match.draw.Substring(0,match.draw.IndexOf("(")).Trim(), away = match.away.Substring(0,match.away.IndexOf("(")).Trim(), bettinglink = match.bettinglink, Displayenddatetime = match.Displayenddatetime,resultlink="" }); } } } xmldoc = GenerateXml(matchlist); crawldata.InsertMatchInfo(xmldoc); } //ds = crawldata.NewRecords(xmldoc); //return ds; return "Command completed successfully"; } catch (Exception ex) { return ex.Message; } }