public override void ParseBets(List <MatchName> matches) { BetList = new List <Bet>(); var tasks = new List <Task>(); int taskCount = 0; foreach (var match in matches) { if (!MatchDict.ContainsKey(match)) { continue; } tasks.Add(Task.Factory.StartNew(() => ParseMatch(MatchDict[match]))); taskCount++; if (taskCount > 20) { Task.WaitAll(tasks.ToArray()); taskCount = 0; } } Task.WaitAll(tasks.ToArray()); Console.WriteLine("Marathon parsed {0} bets at {1}", BetList.Count, DateTime.Now); }
public void ParseMatchList(int index) { HtmlDocument doc = LoadWithTimeout(MatchListUrl[index]); if (doc == null) { return; } HtmlNodeCollection matchNodes = doc.DocumentNode.SelectNodes("//tbody[@class and @data-event-treeid and @data-expanded-event-treeid and @data-live='true']"); if (matchNodes == null) { return; } foreach (var node in matchNodes) { MatchName matchname = GetMatchName(node); string id = String.Empty; id = node.Attributes["data-event-treeid"].Value; MatchName Name = GetMatchName(node); string url = "https://www.marathonbet.com/en/live/" + id; if (MatchDict.ContainsKey(Name)) { return; } MatchDict.Add(Name, url); if (MatchDict.Count == MaximumMatches) { break; } } }
public void ParseMatchList(int index) { HtmlDocument doc = LoadWithTimeout(MatchListUrl); if (doc == null) { return; } HtmlNodeCollection matchList = doc.DocumentNode.SelectNodes(string.Format("//tr[@data-sport='{0}']", type_of_sport[index])); if (matchList == null) { return; } foreach (var node in matchList) { HtmlNodeCollection matchNodes = node.SelectNodes(".//a"); var node2 = matchNodes.First(); if (matchNodes == null) { return; } var idNode = node2.Attributes["id"]; var hrefNode = node2.Attributes["href"]; if (idNode == null || hrefNode == null) { continue; } string id = idNode.Value; if (!id.Contains("match_live_name")) { continue; } string url = "https://www.olimpkz.com/" + hrefNode.Value; url = url.Replace("amp;", ""); // Console.WriteLine(url); string[] name = node2.InnerText.Split(new string[] { " - " }, StringSplitOptions.RemoveEmptyEntries); MatchName matchname = new MatchName(name[0], name[1]); MatchDict.Add(matchname, url); if (MatchDict.Count == MaximumMatches) { break; } } }
public void ParseMatchList(int index) { string html = matchListBrowser.GetSourceAsync().Result; HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(html); HtmlNodeCollection matchList = doc.DocumentNode.SelectNodes("//li[@class='groupedListItem first' or @class='groupedListItem' or @class='groupedListItem last' or @class='groupedListItem first last']"); if (matchList == null) { return; } foreach (var node in matchList) { string All = node.InnerHtml; HtmlDocument All_Doc = new HtmlDocument(); All_Doc.LoadHtml(All); // HtmlNodeCollection h3 = All_Doc.DocumentNode.SelectNodes("//h3"); string l = h3.First().InnerText; if (l == type_of_sport[index]) { HtmlNodeCollection matchNodes = All_Doc.DocumentNode.SelectNodes("//li[@class='groupedListSubItem first' or @class='groupedListSubItem last' or @class='groupedListSubItem' or @class='groupedListSubItem first last']"); if (matchNodes == null) { return; } foreach (var node2 in matchNodes) { string id = String.Empty; id = node2.Attributes["id"].Value; id = id.Remove(0, 2); MatchName Name = GetMatchName(node2); string url = "https://mobile.leonbets.net/mobile/#eventDetails/:" + id; MatchDict.Add(Name, url); if (MatchDict.Count == MaximumMatches) { break; } } } } }