private List <LineDTO> ParseEvent(Event @event) { var random = ProxyList.PickRandom(); var c = CookieDictionary[random].GetData(); try { var converter = new FavBetConverter(); var lineTemplate = converter.CreateLine(@event, Host, Name); if (lineTemplate == null) { return(new List <LineDTO>()); } var markets = ConverterHelper.GetMarketsByEvent(@event.event_id, random, c, Host); return(markets == null ? new List <LineDTO>() : converter.GetLinesFromEvent(lineTemplate, markets)); } catch (WebException e) { Log.Info("Favbet WebException " + JsonConvert.SerializeObject(e)); ParseEvent(@event); } catch (Exception e) { Log.Info("FB Parse event exception " + JsonConvert.SerializeObject(e) + JsonConvert.SerializeObject(c.GetAllCookies())); } return(new List <LineDTO>()); }
protected override void CheckDict() { var hostsToDelete = new List <WebProxy>(); Parallel.ForEach(ProxyList, (host, state) => { try { using (var webClient = new Extensions.WebClientEx(host)) { Console.WriteLine($"Bwin Lines Check Proxy {host.Address}"); webClient.DownloadString(Host); } } catch (Exception) { Console.WriteLine($"Bwin Lines DELETE Proxy {host.Address}"); hostsToDelete.Add(host); } }); foreach (var host in hostsToDelete) { ProxyList.Remove(host); } }
protected override void CheckDict() { var hostsToDelete = new List <WebProxy>(); Parallel.ForEach(ProxyList, (host, state) => { try { Console.WriteLine($"WH check address {host.Address}"); using (var webClient = new Extensions.WebClientEx(host)) { var t = webClient.DownloadString(Host + "bir_xml?action=miniApp"); XDocument.Parse(t); } } catch (Exception e) { hostsToDelete.Add(host); Log.Info($"Wh delete address {host.Address} {host.Credentials.GetCredential(host.Address, "").UserName} listToDelete {hostsToDelete.Count}"); } }); foreach (var host in hostsToDelete) { ProxyList.Remove(host); } }
public void Visit(ProxyList statement) { var property = new CodeMemberProperty(); property.Attributes = MemberAttributes.Override | MemberAttributes.Family; property.Name = "Proxies"; property.HasSet = false; property.Type = new CodeTypeReference(typeof(string[])); property.GetStatements.Add(new CodeVariableDeclarationStatement(new CodeTypeReference(typeof(string[])), "proxies", new CodeArrayCreateExpression(new CodeTypeReference(typeof(string[])), new CodePrimitiveExpression(statement.Proxies.Length))) ); for (int x = 0; x < statement.Proxies.Length; x++) { if (!Proxy.TryParse(statement.Proxies[x].Value)) { Errors.Add(new BadProxyFormat(new Semantic.LineInfo(statement.Proxies[x].Line.Line, statement.Proxies[x].Line.CharacterPosition))); } property.GetStatements.Add(new CodeAssignStatement(new CodeArrayIndexerExpression(new CodeVariableReferenceExpression("proxies"), new CodePrimitiveExpression(x)), new CodePrimitiveExpression(statement.Proxies[x].Value)) ); } property.GetStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression("proxies"))); _mainType.Type.Members.Add(property); }
protected override void CheckDict() { var hostsToDelete = new List <WebProxy>(); Parallel.ForEach(ProxyList, (host, state) => { try { Console.WriteLine($"888sport check address {host.Address}"); using (var webClient = new Extensions.WebClientEx(host)) { webClient.DownloadString("https://eu-offering.kambicdn.org/offering/v2018/888/listView/all/all/all/all/in-play.json?lang=en_GB&market=En"); } } catch (Exception e) { hostsToDelete.Add(host); Log.Info($"888sport delete address {host.Address} {host.Credentials.GetCredential(host.Address, "").UserName} listToDelete {hostsToDelete.Count}"); } }); foreach (var host in hostsToDelete) { ProxyList.Remove(host); } }
public static void Init() { ProxyMap = ProxyMap.Load(); ProxyList = ProxyList.Load(); ProxyAssignStat = new ProxyAssignStatistics(); ProxyAssignStat.Setup(ProxyList, ProxyMap); }
public static async ValueTask <DefaultOptionsHandler> CreateAsync(Options options, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(options.Proxy)) { return(new DefaultOptionsHandler(options)); } if (Proxy.TryParse(options.Proxy, out var proxy) && proxy != null) { return(new DefaultOptionsHandler(options, proxy)); } try { var proxies = await ProxyList.FromFileAsync(options.Proxy, cancellationToken).ConfigureAwait(false); return(proxies.IsEmpty ? new DefaultOptionsHandler(options) : new DefaultOptionsHandler(options, null, proxies)); } catch { return(new DefaultOptionsHandler(options)); } }
public string GetRandomProxy(ProxyList proxies = null) { if (proxies == null) { proxies = _runLists.Proxies; } return(proxies[_random.Next(proxies.Count)]); }
public Worker(Logger Log) { _log = Log; _proxyList = new ProxyList(_log); _timer = new Timer(); _timer.Elapsed += ElapsedEvent; _timer.Stop(); }
protected override void CheckDict() { var listToDelete = new List <WebProxy>(); foreach (var host in ProxyList) { CookieDictionary.Add(host, new CachedArray <CookieContainer>(1000 * 60 * 10, () => { try { var cookies = new CookieCollection(); var result = new CookieContainer(); using (var client = new GetWebClient(host, cookies)) { client.Headers["Referer"] = $"{Host.Replace("www", "play")}NewIndex?act=hdpou&webskintype=2"; var r = client.DownloadString($"{Host.Replace("www", "play")}onebook?act=hdpou"); cookies.Add(client.CookieCollection); var parser = new HtmlParser(); var results = parser.Parse(r); var verfCode = results.QuerySelector("input[name=__RequestVerificationToken]").GetAttribute("value"); cookies.Add(new Cookie("VerfCode", verfCode, "/", new Uri(Host).Host)); } result.Add(cookies); return(result); } catch (Exception) { listToDelete.Add(host); ConsoleExt.ConsoleWriteError($"Dafabet delete address {host.Address} listToDelete {listToDelete.Count}"); } return(null); })); } var tasks = ProxyList.AsParallel().Select(host => Task.Factory.StartNew(state => CookieDictionary[host].GetData(), host)).ToArray(); Task.WaitAll(tasks); foreach (var host in listToDelete) { CookieDictionary.Remove(host); ProxyList.Remove(host); } }
public string GetRandomProxy(ProxyList proxies = null) { _runLists = RunLists.GetOrNewInstance(); if (proxies == null) { proxies = _runLists.proxies; } return(proxies[random.Next(proxies.Count)]); }
/// <summary> /// 获取代理 /// </summary> /// <param name="proxy"></param> /// <param name="port"></param> /// <returns></returns> public static ProxyServer Get(string proxy, int port) { try { return(ProxyList.FirstOrDefault(p => p.proxy == proxy && p.port == port)); } catch { return(null); } }
// //You can use the following additional attributes as you write your tests: // //Use ClassInitialize to run code before running the first test in the class //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ //} // //Use ClassCleanup to run code after all tests in a class have run //[ClassCleanup()] //public static void MyClassCleanup() //{ //} // //Use TestInitialize to run code before running each test //[TestInitialize()] //public void MyTestInitialize() //{ //} // //Use TestCleanup to run code after each test has run //[TestCleanup()] //public void MyTestCleanup() //{ //} // #endregion /// <summary> ///A test for ProxyList`2 Constructor ///</summary> public void ProxyListConstructorTestHelper <TProxy, TSource>(IList <TSource> sourceList, TProxy extraItem) where TProxy : TSource { ProxyList <TProxy, TSource> target = new ProxyList <TProxy, TSource>(sourceList); if (!target.IsReadOnly) { target.Add(extraItem); } Assert.AreEqual(sourceList.Count, target.Count); }
protected override LineDTO[] GetLiveLines() { var lines = new List <LineDTO>(); try { var randomProxy = ProxyList.PickRandom(); string response; using (var wc = new GetWebClient(randomProxy)) { response = wc.DownloadString($"{Host}offering/v2018/888/listView/all/all/all/all/in-play.json?lang=en_GB&market=En"); } var events = JsonConvert.DeserializeObject <EventResult>(response).Events.Where(e => e.Event.path.All(p => !ForbiddenTournaments.Any(t => p.englishName.ContainsIgnoreCase(t)))).ToList(); var tasks = new List <Task>(); tasks.AddRange(events .AsParallel() .WithExecutionMode(ParallelExecutionMode.ForceParallelism) .Select(ev => Task.Factory.StartNew(state => { var lns = ParseEvent(ev); lock (Lock) lines.AddRange(lns); }, ev))); try { Task.WaitAll(tasks.ToArray(), 10000); } catch (Exception e) { Log.Info("S888 Task wait all exception, line count " + lines.Count); Console.WriteLine("S888 Task wait all exception, line count " + lines.Count); } LastUpdatedDiff = DateTime.Now - LastUpdated; ConsoleExt.ConsoleWrite(Name, ProxyList.Count, lines.Count(c => c != null), new DateTime(LastUpdatedDiff.Ticks).ToString("mm:ss")); return(lines.ToArray()); } catch (Exception e) { Log.Info($"ERROR S888 {e.Message} {e.StackTrace}"); } return(new LineDTO[] { }); }
void ProxyExecDown() { int ix = ProxyList.IndexOf(SelectedProxy); LE_Proxy nextProxy = ProxyList[ix + 1]; int ix1 = SelectedProxy.Ix; _dataService.SwapProxy(SelectedProxy, nextProxy); SelectedProxy.Ix = nextProxy.Ix; nextProxy.Ix = ix1; ProxyList[ix + 1] = SelectedProxy; ProxyList[ix] = nextProxy; SelectedProxy = ProxyList[ix + 1]; }
void ProxyExecUp() { int ix = ProxyList.IndexOf(SelectedProxy); LE_Proxy prevProxy = ProxyList[ix - 1]; int ix1 = SelectedProxy.Ix; _dataService.SwapProxy(SelectedProxy, prevProxy); SelectedProxy.Ix = prevProxy.Ix; prevProxy.Ix = ix1; ProxyList[ix - 1] = SelectedProxy; ProxyList[ix] = prevProxy; SelectedProxy = ProxyList[ix - 1]; }
private void LoadProxyGrid() { try { proxyListTab_ProxyListUserControl.grid_Proxy.DataSource = ProxyList.ToList(); addASingleProxyTab_ProxyListUserControl.grid_Proxy.DataSource = ProxyList.ToList(); addBulkProxiesTab_ProxyListUserControl.grid_Proxy.DataSource = ProxyList.ToList(); testProxiesTab_ProxyListUserControl.grid_Proxy.DataSource = ProxyList.ToList(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void LE_LinkToZoneChanged(string obj) { if (DetailSelectedItem.LE_Proxy == null) { //Link Operation int ix = ProxyList.Count; _dataService.LinkToZone(DetailSelectedItem, MasterSelectedItem, ix, (leProxy, error) => { if (error != null) { return; } // Report error here { DetailSelectedItem.LE_Proxy = leProxy; ProxyList.Add(leProxy); } }); if (MasterSelectedItem.PointType != DetailSelectedItem.PointType) { MasterSelectedItem.PointType = DetailSelectedItem.PointType; _dataService.UpdateLightZone(MasterSelectedItem, (i, er) => { }); } MasterSelectedItem.DirectParent = true; DetailSelectedItem.RaiseLinkedToZoneChanged(); MasterSelectedItem.RaiseHasChildrenChanged(); } else { // Unlink _dataService.UnlinkFromZone(DetailSelectedItem, MasterSelectedItem, (updateCount, error) => { }); LE_Proxy proxy = ProxyList.FirstOrDefault(p => p.LightElement.Id == DetailSelectedItem.Id); ProxyList.Remove(proxy); int i = 0; foreach (LE_Proxy leProxy in ProxyList) { leProxy.Ix = i; i++; } DetailSelectedItem.LE_Proxy = null; MasterSelectedItem.DirectParent = false; DetailSelectedItem.RaiseLinkedToZoneChanged(); MasterSelectedItem.RaiseHasChildrenChanged(); } }
public List <Bet> Parse() { List <Bet> rezult = new List <Bet>(); Stopwatch sw = new Stopwatch(); sw.Start(); if (UsingProxy) { _req.Proxy = ProxyClient.Parse(ProxyList.GetRnd()); _req.Proxy.ConnectTimeout = 1500; _req.Proxy.ReadWriteTimeout = 1500; } var response = _req.Get($"{_url}live.html").ToString(); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(response); var links = doc.DocumentNode.SelectNodes("//a").Where(x => x.Attributes["href"] != null && x.Attributes["href"].Value.StartsWith("bet.html?hl=")).Select((x => x.Attributes["href"].Value)).ToList(); List <Task <Bet> > tasks = new List <Task <Bet> >(); foreach (string link in links) { Task <Bet> task = Task <Bet> .Factory.StartNew(delegate() { try { return(ParsePage(link)); } catch (Exception ex) { #if DEBUG Console.WriteLine("Parimatch.inner: " + ex.Message); #endif return(null); } }); tasks.Add(task); } //TODO:Нужно сделать нормальную обработку инфы потоками throw new NotImplementedException("Нужно сделать нормальную обработку инфы потоками"); sw.Stop(); Console.WriteLine($"Parimatch: {rezult.Count} {sw.Elapsed} мс"); return(rezult); }
/// <summary> /// 添加或代理 /// </summary> /// <param name="model"></param> public static void Set(ProxyServer model) { try { ProxyServer proxy = Get(model.proxy, model.port); if (null == proxy) { try { model.id = ProxyList.Max(p => p.id) + 1; } catch { model.id = 1; } lock (ProxyList) { ProxyList.Add(model); } } else { lock (ProxyList) { proxy.anonymity = model.anonymity; proxy.anonymityen = model.anonymityen; proxy.country = model.country; proxy.countryen = model.countryen; proxy.description = model.description; proxy.isvip = model.isvip; proxy.port = model.port; proxy.proxy = model.proxy; proxy.proxypassword = model.proxypassword; proxy.proxyusername = model.proxyusername; proxy.response = model.response; proxy.status = model.status; proxy.testdate = model.testdate; proxy.type = model.type; proxy.userid = model.userid; proxy.userip = model.userip; proxy.username = model.username; } } } catch { } }
public void Start() { SoundPlayer.PlayAlter(); proxyEnumerator = ProxyList.GetEnumerator(); isRunnig = true; LogManager.InfoWithCallback(string.Format("开始对:{0} 文件进行代理测速 ", ProxyFile, this.Server.Header)); for (int i = 0; i < threadCount; i++) { ThreadPool.QueueUserWorkItem(delegate { while (true) { ProxyItem proxy = GetCurrentProxy(); if (null == proxy || this.isDisposing || !isRunnig) { if (Interlocked.Increment(ref finishCount) == threadCount) { SaveChunk(true); //SaveSpeedProxy(); } return; } using (ProxyHttper httper = new ProxyHttper(proxy)) { httper.GetHttpTime(this.Server.LoginPostActionUrl); } lock (resultObj) { sortedProxyList.Add(proxy.AccessTime, proxy); if (proxy.AccessTime > 0 & !proxy.IsNeedCaptcha) { sortedSucceedProxyList.Add(proxy.AccessTime, proxy); } if (sortedProxyList.Count >= chunkCount) { SaveChunk(false); } } LogManager.InfoWithCallback(string.Format("{0}、 代理:{1} 访问时间:{2:f2} 秒,{3} {4} ", proxy.ID, proxy.IP, proxy.AccessTime, proxy.IsNeedCaptcha ? " ,需要验证码" : "", proxy.AccessTime < 0 ? " ,代理无法访问" : "")); } }); } }
public static List <ProxyList> GetProxyLists(string pr = "") { var filepath = "Data/ProfileData/proxies.csv"; List <ProxyList> ls = new List <ProxyList>(); if (File.Exists(filepath)) { var count = 0; using (var reader = new StreamReader(filepath)) { List <string> listA = new List <string>(); List <string> listB = new List <string>(); while (!reader.EndOfStream) { ProxyList obj = new ProxyList(); var line = reader.ReadLine(); var values = line.Split(','); if (line == "") { } else { if (pr == "") { count++; obj.name = values[0]; obj.values = values[1]; ls.Add(obj); } else { if (values[0] == pr) { count++; obj.name = values[0]; obj.values = values[1]; ls.Add(obj); } } } } reader.Dispose(); } } return(ls); }
/// <summary> /// 删除代理 /// </summary> /// <param name="proxy"></param> /// <param name="port"></param> public static void Remove(string proxy, int port) { try { ProxyServer model = Get(proxy, port); if (null != model) { lock (ProxyList) { ProxyList.Remove(model); } } } catch { } }
/// <summary> /// 删除代理 /// </summary> /// <param name="model"></param> public static void Remove(ProxyServer model) { try { ProxyServer proxy = Get(model.proxy, model.port); if (null != proxy) { lock (ProxyList) { ProxyList.Remove(proxy); } } } catch { } }
private List <string> UpdateUrls() { var st = new Stopwatch(); st.Start(); var s = Empty; var proxy = ProxyList.PickRandom(); var retry = 0; while (retry < 3) { try { using (var webClient = new Extensions.WebClientEx(proxy)) s = webClient.DownloadString($"{Host}bir_xml?action=miniApp"); retry = 3; } catch (WebException) { retry++; } catch (Exception e) { Log.Info("WilliamHill UpdateUrls error " + JsonConvert.SerializeObject(e)); retry = 3; } } var document = XDocument.Parse(s); var ids = from m in document.Elements("miniApp").Elements("Events").Elements("Event") select m.Attribute("ob_id").Value; var urls = ids .Select(x => Format("{1}bir_xml?action=event&version=1&ev_id={0}", x, Host)) .ToList(); return(urls); }
void PopulateList() { Proxies = grabber.Proxies; ProxyList.Clear(); ProxyList.Columns.Add("Country"); ProxyList.Columns.Add("Anonomity"); ProxyList.Columns.Add("Speed"); ProxyList.Columns.Add("Protocol"); ProxyList.Columns.Add("IP"); ProxyList.Columns.Add("Port"); for (int i = 0; i < Proxies.Count; i++) { var root = ProxyList.Items.Add(Proxies[i].country); root.SubItems.Add(Proxies[i].anonimity); root.SubItems.Add(Proxies[i].speed); root.SubItems.Add(Proxies[i].protocol); root.SubItems.Add(Proxies[i].ip); root.SubItems.Add(Proxies[i].port); } UpdateButton.UseWaitCursor = false; UpdateButton.Enabled = true; this.UseWaitCursor = false; }
protected override LineDTO[] GetLiveLines() { try { var tempData = CachedArray.GetData(); if (tempData.NeedUpdate) { using (var wc = new Extensions.WebClientEx(ProxyList.PickRandom())) { wc.Encoding = Encoding.Default; wc.Headers["Referer"] = tempData.Referer; tempData.Html = wc.DownloadString(tempData.Url); } } else { tempData.NeedUpdate = true; } var converter = new ParimatchLineConverter(); var lines = converter.Convert(tempData, Name); LastUpdatedDiff = DateTime.Now - LastUpdated; ConsoleExt.ConsoleWrite(Name, ProxyList.Count, lines.Length, new DateTime(LastUpdatedDiff.Ticks).ToString("mm:ss")); return(lines); } catch { return(new LineDTO[] { }); } }
private TempData UpdateUrls(object data) { Func <string, string> load = x => { using (var wc = new Extensions.WebClientEx(ProxyList.PickRandom())) { wc.Headers["Upgrade-Insecure-Requests"] = "1"; wc.Headers["Referer"] = $"{Host}/en/live.html"; return(wc.DownloadString(x)); } }; var url = $"{Host}/en/live_as.html?curs=0&curName=$&shed=0"; var html = load(url); var parser = new HtmlParser(); var doc = parser.Parse(html); var inputs = doc.QuerySelectorAll("input.ch_l"); var values = inputs.Select(x => x.GetAttribute("value").ToInt()).ToList(); var hl = string.Join(",", values); var he = string.Join(",", values.OrderBy(x => x)); var tempData = new TempData { Referer = $"{Host}/en/bet.html?ARDisabled=on&hl={hl}" }; tempData.Html = load(tempData.Referer); tempData.NeedUpdate = false; tempData.Url = $"{Host}/en/live_ar.html?ARDisabled=on&hl={hl}&he={he}&curs=0&curName=$"; return(tempData); }
private List <LineDTO> ParseEvent(EventSub @event) { var random = ProxyList.PickRandom(); try { var converter = new S888LineConverter(); var lineTemplate = converter.CreateLine(@event, Host, Name); if (lineTemplate == null) { return(new List <LineDTO>()); } var eventFull = ConverterHelper.GetFullLine(@event.Event.id, random, Host); if (eventFull == null) { return(new List <LineDTO>()); } return(converter.GetLinesFromEvent(lineTemplate, eventFull)); } catch (WebException e) { Log.Info("888sport WebException " + JsonConvert.SerializeObject(e)); ParseEvent(@event); } catch (Exception e) { Log.Info("888sport Parse event exception " + JsonConvert.SerializeObject(e)); } return(new List <LineDTO>()); }
public void Visit(ProxyList list, CommonTree tree) { SetLine(list, tree); Parent(tree).Children.Add(list); VisitChildren(tree); }
private void BtnProxyListTemizle_Click(object sender, EventArgs e) { ProxyList.Clear(); }
private void SaveProxyList(string location, ProxyList proxyList) { File.WriteAllText(location, Serializer.Serialize(proxyList.Proxies)); }
public ProxyStorage(ProxyList proxyList) { this.proxyList = proxyList; }