Beispiel #1
0
        public static ProxyClass ProxyListCreation(ProxyClass ProxyClass)
        {
            ChromeOptions options = new ChromeOptions();

            options.AddArgument("--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36");
            options.AddArgument("--mute-audio");
            options.AddArgument("--ignore-certificate-errors");
            options.AddArgument("--disable-popup-blocking");
            options.AddArgument("--incognito");
            //options.BinaryLocation = "/Users/nbeny/Desktop/Google Chrome.app/Contents/MacOS/Google Chrome";
            ChromeDriver Driver = new ChromeDriver(options);

            Driver.Manage().Timeouts().PageLoad               = TimeSpan.FromSeconds(60);
            Driver.Manage().Timeouts().ImplicitWait           = TimeSpan.FromSeconds(60);
            Driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(60);

            Driver.Navigate().GoToUrl(ProxyClass.urlCheck);
            Thread.Sleep(20);

            ProxyClass = ProxyClass.GetIpAndPort(ProxyClass, Driver);

            Driver.Close();

            options.AddArguments("--proxy-server=" + ProxyClass.ListIp[1] + ":" + ProxyClass.ListPort[1]);

            /*
             * //Create a new proxy object
             * var proxy = new WebProxy();
             * //Set the http proxy value, host and port.
             * proxy.Address = ProxyClass.IP + ":" + ProxyClass.Port;
             * //Set the proxy to the Chrome options
             * ChromeOptions.Proxy = proxy;
             */

            Driver = new ChromeDriver(options);
            Driver.Manage().Timeouts().PageLoad               = TimeSpan.FromSeconds(60);
            Driver.Manage().Timeouts().ImplicitWait           = TimeSpan.FromSeconds(60);
            Driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(60);

            ProxyClass.Driver = Driver;

            ProxyClass = TestProxy(ProxyClass);

            ProxyClass.Driver.Close();

            return(ProxyClass);
        }
Beispiel #2
0
        public static ProxyClass TestProxy(ProxyClass Proxy)
        {
            string X = "http://example.com/";

            // Navigates to the url
            Proxy.Driver.Navigate().GoToUrl(X);

            var page       = Proxy.Driver.PageSource;
            var DocRelated = new HtmlDocument();

            DocRelated.LoadHtml(page);
            var quitAccessSite = DocRelated.DocumentNode.SelectNodes("//*[@id=\"main-message\"]/h1/span");
            var quitCapcha     = DocRelated.DocumentNode.SelectNodes("//*[@id=\"cf-error-details\"]/div[1]/h2/span");

            if (quitAccessSite != null || quitCapcha != null)
            {
                if (quitAccessSite != null)
                {
                    Console.WriteLine(quitAccessSite[0].InnerText);
                }
                if (quitCapcha != null)
                {
                    Console.WriteLine(quitCapcha[0].InnerText);
                }
                Console.WriteLine("delete: [" + Proxy.ListIp[Proxy.Ip] + ":" + Proxy.ListPort[Proxy.Port] + "]");
                Proxy.ListIp.RemoveAt(Proxy.Ip);
                Proxy.ListPort.RemoveAt(Proxy.Port);
                Proxy.NbProxy--;
                if (Proxy.Ip >= Proxy.NbProxy)
                {
                    Proxy.Ip   = 0;
                    Proxy.Port = 0;
                    return(Proxy);
                }
            }
            if (Proxy.Ip >= Proxy.NbProxy)
            {
                return(Proxy);
            }
            Proxy.Ip++;
            Proxy.Port++;
            ProxyClass.ChangeProxy(Proxy, Proxy.Ip, Proxy.Port);
            TestProxy(Proxy);
            return(Proxy);
        }
Beispiel #3
0
        public static ProxyClass GetIpAndPort(ProxyClass ProxyClass, ChromeDriver Driver)
        {
            Driver.Navigate().GoToUrl(ProxyClass.urlProxy);

            IWebElement X500 = Driver.FindElementByXPath(ProxyClass.X500);

            X500.Click();

            IWebElement X501 = Driver.FindElementByXPath(ProxyClass.X500);

            X501.Click();

            var page = Driver.PageSource;
            var Doc  = new HtmlDocument();

            Doc.LoadHtml(page);
            Thread.Sleep(2000);

            for (int i = 4; i < 404; i++)
            {
                var Https = Doc.DocumentNode.SelectNodes(ProxyClass.XhttpsStart + i.ToString() + ProxyClass.XhttpsEnd);
                if (Https != null)
                {
                    var   Hia     = Doc.DocumentNode.SelectNodes(ProxyClass.XhiaStart + i.ToString() + ProxyClass.XhiaEnd);
                    var   Latency = Doc.DocumentNode.SelectNodes(ProxyClass.XLatencyStart + i.ToString() + ProxyClass.XLatencyEnd);
                    float lat     = float.Parse(Latency[0].InnerText.Trim(), CultureInfo.InvariantCulture.NumberFormat);
                    if (Https[0].InnerText.Contains("S") && Hia[0].InnerText.Contains("HIA") && lat < 1)
                    {
                        var IpAdress = Doc.DocumentNode.SelectNodes(ProxyClass.XIpAdressStart + i.ToString() + ProxyClass.XIpAdressEnd);
                        if (!IpAdress[0].InnerText.Contains("5.135.20.71"))
                        {
                            ProxyClass.ListIp.Add(IpAdress[0].InnerText);
                            var IpPort = Doc.DocumentNode.SelectNodes(ProxyClass.XPortStart + i.ToString() + ProxyClass.XPortEnd);
                            ProxyClass.ListPort.Add(IpPort[0].InnerText);
                        }
                    }
                }
            }

            ProxyClass.NbProxy = ProxyClass.ListIp.Count;

            return(ProxyClass);
        }
Beispiel #4
0
        public static ProxyClass NewDriverProxy(ProxyClass Proxy)
        {
            ProxyClass ProxyClass = new ProxyClass();

            foreach (var item in Proxy.ListIp)
            {
                ProxyClass.ListIp.Add(item);
            }
            foreach (var item in Proxy.ListPort)
            {
                ProxyClass.ListPort.Add(item);
            }

            ProxyClass.NbProxy = Proxy.NbProxy;
            ProxyClass.Ip      = 0;
            ProxyClass.Port    = 0;

            ChromeOptions options = new ChromeOptions();

            options.AddArgument("--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36");
            options.AddArgument("--mute-audio");
            options.AddArgument("--ignore-certificate-errors");
            options.AddArgument("--disable-popup-blocking");
            options.AddArgument("--incognito");
            //options.BinaryLocation = "/Users/nbeny/Desktop/Google Chrome.app/Contents/MacOS/Google Chrome";
            options.AddArguments("--proxy-server=" + ProxyClass.ListIp[0] + ":" + ProxyClass.ListPort[0]);

            ChromeDriver Driver = new ChromeDriver(options);

            Driver.Manage().Timeouts().PageLoad               = TimeSpan.FromSeconds(60);
            Driver.Manage().Timeouts().ImplicitWait           = TimeSpan.FromSeconds(60);
            Driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(60);

            ProxyClass.Driver = Driver;

            return(ProxyClass);
        }
Beispiel #5
0
        public void Ft_Thread2()
        {
            Console.WriteLine(Thread.GetDomain());

            for (int i = 0; i < 10; i++)
            {
                if (i == 0)
                {
                    Thread thr = Thread.CurrentThread;
                    Console.WriteLine(i + " New Thread2 activate");

                    ProxyClass ProxyClass = ProxyClass.NewDriverProxy(Proxy);
                    YggUrl.StartScrapper2(ProxyClass);



                    EndThread2 = 1;
                }
                else
                {
                    EndThread2 = 2;
                }
            }
        }
Beispiel #6
0
        public void Ft_Thread1()
        {
            Console.WriteLine(Thread.GetDomain());

            for (int i = 0; i < 10; i++)
            {
                if (i == 0)
                {
                    Thread thr = Thread.CurrentThread;
                    Console.WriteLine(i.ToString() + " New Thread2 activat");

                    ProxyClass ProxyClass = ProxyClass.NewDriverProxy(Proxy);
                    YggUrl.StartScrapper1(ProxyClass);

//                  C:\Users\ynebo\Documents\InfinityProxy\Infinity\Infinity\Proxy\FtTread.cs

                    EndThread1 = 1;
                }
                else
                {
                    EndThread1 = 2;
                }
            }
        }
Beispiel #7
0
 public FtThread(ProxyClass ProxyClass)
 {
     Proxy = ProxyClass;
 }