public BuisnessTester(BuisnessData data, BuisnessAgression aggression = BuisnessAgression.Root, BuisnessSpeed speed = BuisnessSpeed.Min5) { Aggression = aggression; Speed = speed; data.DataUpdated += Data_DataUpdated; }
static void LoadData(string page) { var updateData = new BuisnessData { Pair = page.Substring(page.LastIndexOf("/") + 1) }; Regex time = new Regex(@">\d{2}:\d{2}:\d{2}"); Regex doubleRegex = new Regex(@"[^0-9,]"); Regex percent = new Regex(@"[\-\+]\d{1,3},\d{1,2}%"); lock (UI) { UI.Add(updateData); } while (true) { var data = GetResponse(page); DateTime AccessTime = DateTime.Now; string document = data.Result; string documentData = time.Match(document).Value; if (documentData != "") { AccessTime = Convert.ToDateTime(time.Match(document).Value.Substring(1)); } else { updateData.AccessDate = AccessTime; if (!updateData.Pair.Contains("[Closed]")) { updateData.Pair = $"[Closed] {updateData.Pair}"; } else { System.Threading.Thread.Sleep(new TimeSpan(0, 2, 0)); } } if (AccessTime != updateData.AccessDate) { updateData.AccessDate = AccessTime; string truePid = doubleRegex.Replace(document.Substring("last_last", "/span>").Replace(".", ""), ""); Double.TryParse(truePid, out double doublePid); updateData.Pid = doublePid; Double.TryParse(percent.Match(document).Value.Replace("%", ""), out double doublePercent); updateData.Percent = doublePercent; string substring = document.Substring("Резюме</td>", "</tr>"); string[] predictians = Regex.Split(substring, "</td>"); Regex regex = new Regex(@"[^А-я, ]"); for (int i = 0; i < predictians.Length; i++) { predictians[i] = regex.Replace(predictians[i], "").TrimStart(' ').TrimEnd(' '); } if (predictians.Length > 2) { updateData.Min5 = GetSyn(predictians[0]); updateData.Min15 = GetSyn(predictians[1]); } } } }