Exemple #1
0
        static void TestProxy()
        {
            var avito              = new Avito();
            var login              = "******";
            var password           = "******";
            var url                = "https://www.avito.ru";
            var ipExceptionsString = new[] { "Доступ с вашего IP-адреса временно ограничен", "Доступ временно заблокирован", "Ошибка при установлении защищённого соединения" };
            var successCount       = 0;

            for (var i = 0; i < 100; i++)
            {
                ProxyCardCheckCache proxy = ProxyHelper.GetProxy(url, ipExceptionsString, 1000);
                if (proxy == null)
                {
                    ConsoleHelper.SendException($"Command execute crash and stoped, proxy not found or service not available");
                    //throw new Exception("Command execute crash and stoped, proxy not found or service not available");
                }
                else
                {
                    FirefoxHelper.ExecuteWithVisual(browser =>
                    {
                        browser.Navigate().GoToUrl("https://www.avito.ru/moskva/bytovaya_elektronika");
                        var success = avito.Auth(browser, login, password);
                        if (success)
                        {
                            successCount++;
                        }
                    }, proxy, 50, true);
                }
            }
            ConsoleHelper.SendException($"Success count is {successCount}");
        }
Exemple #2
0
        public AllSites(List <District> listDistricts, List <Metro> listMetros, List <ProxyInfo> listProxy) : base(listDistricts, listMetros, listProxy)
        {
            bkn   = new BKN(listDistricts, listMetros, listProxy);
            bn    = new BN(listDistricts, listMetros, listProxy);
            elms  = new ELMS(listDistricts, listMetros, listProxy);
            avito = new Avito(listDistricts, listMetros, listProxy);

            bkn.Filename   = filename;
            bn.Filename    = filename;
            elms.Filename  = filename;
            avito.Filename = filename;
        }
Exemple #3
0
        static void TestRegistration()
        {
            var avito = new Avito();

            var login    = "******";
            var password = "******";

            FirefoxHelper.ExecuteWithVisual(browser =>
            {
                browser.Navigate().GoToUrl("https://www.avito.ru/moskva/bytovaya_elektronika");
                avito.Auth(browser, login, password);
            }, null, 100, true);
        }
Exemple #4
0
        static void TestActivate()
        {
            var avito = new Avito();
            var task  = new TaskAccessCheckCache
            {
                Login    = "******",
                Password = "******"
            };

            FirefoxHelper.ExecuteWithVisual(browser =>
            {
                browser.Navigate().GoToUrl("https://www.avito.ru/moskva/bytovaya_elektronika");
                avito.ActivateBulletins(browser, task);
            }, null, 100);
        }
Exemple #5
0
        static void TestInstanceActivate()
        {
            var avito = new Avito();
            var task  = new TaskInstanceActivationCache
            {
                Login    = "******",
                Password = "******",
                Url      = @"https://www.avito.ru/podolsk/telefony/apple_iphone_6_16gb_zolotoy_1717723420"
            };

            FirefoxHelper.ExecuteWithVisual(browser =>
            {
                browser.Navigate().GoToUrl("https://www.avito.ru/moskva/bytovaya_elektronika");
                avito.ActivateBulletin(browser, task);
            }, null, 100);
        }
Exemple #6
0
        static void TestForwardNumber()
        {
            var avito       = new Avito();
            var accessCache = new AccessCache
            {
                IsForwarding = true,
                Login        = "******",
                Password     = "******",
            };

            FirefoxHelper.ExecuteWithVisual(browser =>
            {
                browser.Navigate().GoToUrl("https://www.avito.ru/moskva/bytovaya_elektronika");
                avito.Registration(browser, accessCache);
            }, null, 100, true);
            //const string forwardNumber = "9264200230";
            //OnlineSimHelper.GetForward(forwardNumber);
        }
Exemple #7
0
        static void TestInstanceStatistics()
        {
            var avito = new Avito();
            var task  = new TaskInstanceStatisticsCache
            {
                InstanceId = new Guid("8BB27650-462E-497E-B9A5-044AA1C66FAD"),
                Url        = "https://www.avito.ru/podolsk/telefony/iphone_6s_64gb_seryy_kosmos_1259355638",
            };

            FirefoxHelper.ExecuteWithVisual(browser =>
            {
                browser.Navigate().GoToUrl("https://www.avito.ru/moskva/bytovaya_elektronika");
                var stat = avito.GetInstanceStatistics(browser, task);
                if (stat != null)
                {
                    var instance   = BulletinInstanceHelper.Get(task.InstanceId);
                    instance.Views = stat.Value;
                    BulletinInstanceHelper.Save(instance);
                }
            }, null, 100);
        }
Exemple #8
0
        static void TestCollectMessages()
        {
            var avito = new Avito();
            var task  = new TaskMessageCollectorCache
            {
                AccessId = new Guid("7D4D06F2-8C3A-4E7B-82A2-A815427BB7A2"),
                Login    = "******",
                Password = "******"
            };

            FirefoxHelper.ExecuteWithVisual(browser =>
            {
                browser.Navigate().GoToUrl("https://www.avito.ru/moskva/bytovaya_elektronika");
                var msgs = avito.CollectMessages(browser, task);
                if (msgs.Any())
                {
                    var access         = AccessHelper.GetAccess(task.AccessId);
                    access.LastMessage = msgs.Max(q => q.PublicationDate);
                    AccessHelper.Save(access);
                    MessageServiceHelper.Save(msgs);
                }
            }, null, 100);
        }
Exemple #9
0
        static void TestGetStatistics()
        {
            var avito = new Avito();
            var task  = new TaskAccessCheckCache
            {
                AccessId = new Guid("BBC4B038-7309-4299-BB59-D8F0119EB7B5"),
                Login    = "******",
                Password = "******"
            };

            FirefoxHelper.ExecuteWithVisual(browser =>
            {
                browser.Navigate().GoToUrl("https://www.avito.ru/moskva/bytovaya_elektronika");
                var stat = avito.GetAccessStatistics(browser, task);
                if (stat != null)
                {
                    var access      = AccessHelper.GetAccess(task.AccessId);
                    access.Views    = stat.Views;
                    access.Messages = stat.Messages;
                    access.Calls    = stat.Calls;
                    AccessHelper.Save(access);
                }
            }, null, 100);
        }
Exemple #10
0
        static void Main(string[] args)
        {
            Avito a = new Avito();

            a.Login(Settings.login, Settings.password);
            a.Init();
            a.SetCaptchaRecognizer(new CaptchaService(Settings.token));
            //a.SetCaptchaRecognizer(new lol());

            List <Advertisement> all = a.GetAll();
            User u = a.GetUserInfo();

            foreach (Advertisement x in all)
            {
                if (x.Id == 0)
                {
                    continue;
                }
                x.User.Name  = u.Name;
                x.User.Email = u.Email;
                try
                {
                    a.Post(x);
                }
                catch (WrongAdvertisementException e)
                {
                    Console.WriteLine("Ad Problems!");
                    continue;
                }
                catch (CaptchaException e)
                {
                    Console.WriteLine("Captcha Problems!");
                    continue;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Other problems!");
                    continue;
                }
                a.Close(x);
            }



            /*
             * List<Region> reg = a.GetRegions();
             * UserLocation loc = a.GetDefaultLocation();
             * List<City> cities = a.GetCities(15);
             * while (true)
             * {
             *      Console.Write("> ");
             *      string command = Console.ReadLine();
             *      if (command == "exit")
             *              break;
             *      else if (command == "list")
             *              for (int i = 0; i < reg.Count; i++)
             *                      Console.WriteLine("{0}. {1}", i, reg[i]);
             *      else if (command == "show")
             *      {
             *              if (cities == null)
             *                      Console.WriteLine("Cities is null!");
             *              else foreach (City x in cities)
             *                              Console.WriteLine(x);
             *      }
             *      else if (command.Substring(0,3) == "get")
             *              cities = a.GetCities(reg[Int32.Parse(command.Substring(4))].Id);
             *      else Console.WriteLine("Wrong command!");
             * }*/
        }
Exemple #11
0
        static void Main(string[] args)
        {
            var av = new Avito();

            av.Run();
        }