Exemple #1
0
        public void TestGetFieldAvito()
        {
            AvitoHandler aH  = new AvitoHandler();
            var          res = aH.GetFieldAvito("http://m.avito.ru/pskov/mebel_i_interer/stol_dlya_shkolnika_220533018");

            Assert.AreEqual(null, res);
        }
Exemple #2
0
        private async void StartButton_Click(object sender, EventArgs e)
        {
            //var socksList = Helpers.GetIpEndOfFile(@"E:\ProxyList\socks.txt");
            //var ipWorks = new List<IPEndPoint>();//Helpers.GetIpEndOfFile(@"E:\ProxyList\socksWork.txt");
            //int s5 = 0, s4 = 0;
            //Parallel.ForEach(socksList, s =>
            //{
            //    var zxc = Socks.GetTypeSocks(s);
            //    if (zxc != TypeSocks.Error)
            //    {
            //        ipWorks.Add(s);
            //        if (zxc == TypeSocks.Socks5)
            //            s5++;
            //        if (zxc == TypeSocks.Socks4)
            //            s4++;
            //    }

            //});
            var a   = new AvJs("123123123");
            var tre =
                a.q_a_bb("{\"a\":{\"af\":1382981724491,\"aa\":1,\"ab\":10,\"ac\":9,\"ae\":\"\",\"ad\":\"BYCR5JHJJDRQZK2VPDDQ\",\"ag\":1382371709662,\"ah\":1382981634346,\"cg\":\"SG0978FE8DF36DE98AC942EC221DCD35404566F861\",\"ai\":\"Win32\",\"aj\":\"http://m.avito.ru/pskov/kvartiry\",\"ak\":1},\"b\":[{\"bd\":\"\",\"be\":\"\",\"bk\":-1,\"bl\":0,\"bj\":\"ru\",\"bo\":[],\"bm\":false,\"bn\":{},\"bv\":[],\"bt\":false,\"bu\":{},\"by\":[],\"cd\":0,\"ba\":1382981634346,\"bb\":90145,\"bc\":36612,\"ch\":\"Etc/GMT-4\"}]}");
            //File.WriteAllLines(@"E:\ProxyList\socksWork.txt", ipWorks.Select(x => x.Address + ":" + x.Port));
            AvitoHandler aH = new AvitoHandler();
            var          sa = aH.GetFieldAvito("http://m.avito.ru/sankt-peterburg/avtomobili_s_probegom/toyota_will_2002_227393083");

            Helpers.SaveInOnTypeProxy(@"E:\ProxyList\ipMyFind.txt");
            var         ipRus = File.ReadAllLines(@"E:\ProxyList\GeoipRus1.txt");
            List <long> time  = new List <long>();

            foreach (var str in ipRus)
            {
                var rangeIp = Helpers.GetRangeIpOfStr(str);
                var temp    = rangeIp[0].ToString();
                var temp1   = rangeIp[1].ToString();
                //Перебор {111.111}.111.111 где {p0}.i.j
                var    ip0 = temp.Substring(0, temp.IndexOf(".", temp.IndexOf(".") + 1));
                var    ip1 = temp1.Substring(0, temp1.IndexOf(".", temp1.IndexOf(".") + 1));
                int    iEnd, iBegin, zBegin = 0, zEnd = 1;
                string one = rangeIp[0].ToString().Substring(0, temp.IndexOf("."));
                if (ip0.Equals(ip1))
                {
                    temp = temp.Replace(ip0 + ".", "");
                    var iStr = temp.Substring(0, temp.IndexOf("."));
                    iBegin = Convert.ToInt32(iStr);
                    temp1  = temp1.Replace(ip0 + ".", "");
                    iStr   = temp1.Substring(0, temp1.IndexOf("."));
                    iEnd   = Convert.ToInt32(iStr);
                }
                else
                {
                    //111.{p0}.111.111
                    ip0    = temp.Substring(temp.IndexOf(".") + 1, temp.IndexOf(".", temp.IndexOf(".")));
                    ip1    = temp1.Substring(temp1.IndexOf(".") + 1, temp1.IndexOf(".", temp1.IndexOf(".")));
                    zBegin = Convert.ToInt32(ip0);
                    zEnd   = Convert.ToInt32(ip1);
                    temp   = temp.Replace(temp.Substring(0, temp.IndexOf(".", temp.IndexOf(".") + 1)) + ".", "");
                    var iStr = temp.Substring(0, temp.IndexOf("."));
                    iBegin = Convert.ToInt32(iStr);
                    temp1  = temp1.Replace(temp1.Substring(0, temp1.IndexOf(".", temp1.IndexOf(".") + 1)) + ".", "");
                    iStr   = temp1.Substring(0, temp1.IndexOf("."));
                    iEnd   = Convert.ToInt32(iStr);
                }

                var st  = new Stopwatch();
                var sad = new List <string>();
                sad.Add("--------------------------------------------------------------------------------------------------");
                sad.Add("-----------------" + str + " - " + rangeIp[0].ToString() + ":" + rangeIp[1].ToString() + "----------");
                sad.Add("--------------------------------------------------------------------------------------------------");
                st.Start();
                int zx = 0;
                for (int z = zBegin; z <= zEnd; z++)
                {
                    List <string> p1080 = new List <string>();
                    Parallel.For(iBegin, iEnd + 1, /* new ParallelOptions() {MaxDegreeOfParallelism = 10},*/ i =>
                    {
                        string ipStr = string.Empty;
                        if (zEnd == 1)
                        {
                            ipStr = string.Format("{0}.{1}.0-255", ip0, i);
                        }
                        else
                        {
                            ipStr = string.Format("{0}.{1}.{2}.0-255", one, z, i);
                        }
                        var res = SearchProxy.GetOpenProxyPorts(ipStr);
                        zx++;
                        if (res.Contains("open"))
                        {
                            sad.Add(res);
                        }
                        if (res.Contains("1080"))
                        {
                            p1080.Add(res);
                        }
                    });
                    File.AppendAllLines(@"E:\ProxyList\ScanSocks.txt", p1080);
                    if (zEnd == 1)
                    {
                        break;
                    }
                }
                st.Stop();
                sad.Add("------------------------------------------------------------------------------------------");
                File.AppendAllLines(@"E:\ProxyList\Scan.txt", sad);
                time.Add(st.ElapsedMilliseconds);
            }



            var pathProxyList = @"E:\ProxyList\proxy.txt";

            Proxy.FormattingProxyFile(@"E:\ProxyList\ProxyListWhiteSpace.txt", pathProxyList);
            var proxyList = Proxy.ReadIpList(pathProxyList);
            var error400s = new List <string>();

            string[] headerProxies = { "x-via",       "cdn-src-ip",   "x-bluecoat-via",
                                       "mt-proxy-id", "x-real-ip",    "x-proxy-id",    "x-forwarded-for", "via"
                                       ,              "max-forwards", "x-via",         "x-forwarded-server", "x-forwarded-host" };
            if (proxyList != null && proxyList.Any())
            {
                var myIp   = Proxy.GetIp(null);
                var ipWork = new List <IpAdr>();
                Parallel.ForEach(proxyList, s =>
                {
                    var adr   = s.Trim();
                    var endIp = adr.IndexOf(":");
                    if (endIp < 1)
                    {
                        endIp = adr.IndexOf(" ");
                    }

                    string ip = adr.Substring(0, endIp);
                    int port  = Int32.Parse(adr.Substring(endIp + 1));
                    var proxy = new Proxy(new WebProxy(ip, port));
                    if (proxy.IsPing(ip))
                    {
                        var send = proxy.SocketSendHttp();
                        if (!string.IsNullOrEmpty(send))
                        {
                            var status = send.Substring(9, 3);
                            if (status.Substring(0, 1) == "2")
                            {
                                var ipProxy = proxy.GetIp();

                                if (!ipProxy.Equals(""))
                                {
                                    var countryName = proxy.GetGeolocation();
                                    bool visible    = ipProxy.Equals(myIp);
                                    var ipSecurity  = IpSecurity.Transparent;
                                    if (!visible)
                                    {
                                        if (!ipProxy.Equals(ip))
                                        {
                                            ipProxy = ip;
                                        }
                                        foreach (var header in headerProxies)
                                        {
                                            if (send.IndexOf(header) > 0)
                                            {
                                                ipSecurity = IpSecurity.Anonymous;
                                                break;
                                            }
                                        }
                                        if (ipSecurity == IpSecurity.Transparent)
                                        {
                                            ipSecurity = IpSecurity.Elite;
                                        }
                                    }
                                    ipWork.Add(new IpAdr()
                                    {
                                        Ip       = ip,
                                        Port     = port,
                                        Security = ipSecurity,
                                        TimePing = proxy.TimePing,
                                        Country  = countryName
                                    });
                                }
                            }
                            else if (status.Equals("400"))
                            {
                                error400s.Add(ip + ":" + port.ToString());
                            }
                        }
                    }
                });
                File.WriteAllLines(@"E:\ProxyList\proxyElite.txt", ipWork.Where(x => x.Security == IpSecurity.Elite).Select(x => x.Ip + ":" + x.Port));
                File.WriteAllLines(@"E:\ProxyList\proxy.txt", ipWork.Select(x => x.Ip + ":" + x.Port));
                File.WriteAllLines(@"E:\ProxyList\proxyError400.txt", error400s);
                WriteCSV(ipWork, @"E:\ProxyList\proxy.csv");
            }
            var ret = 0;
        }