Esempio n. 1
0
        public async void execute()
        {
            Yandex yandex = new Yandex();

            if (!yandex.isValidRegion())
            {
                yandex.open_settings();
            }
            yandex.change_search_pos_count();

            try
            {
                while (true)
                {
                    kwMutext.WaitOne();

                    var globalOffset = !settings.KeyExists("offset", SETTINGS_SECTION) ?
                                       long.Parse(settings.Write("offset", "" + offset, SETTINGS_SECTION)) :
                                       long.Parse(settings.Read("offset", SETTINGS_SECTION));

                    this.offset = Math.Max(this.offset, globalOffset);

                    this.limit    = STEP;
                    this.offset  += this.limit;
                    globalOffset += this.limit;
                    settings.Write("offset", "" + Math.Max(this.offset, globalOffset), SETTINGS_SECTION);

                    List <DBKeyword> list = this.listKeywords(offset, limit);
                    if (list == null)
                    {
                        kwMutext.ReleaseMutex();
                        break;
                    }

                    kwMutext.ReleaseMutex();

                    foreach (DBKeyword kw in list)
                    {
                        yandex.search(kw);
                        Thread.Sleep(YandexUtils.rndSleep());
                    }
                }
            }catch {
                Task.Run(() => (new SelfRestarter(TimeSpan.FromSeconds(25))).execute());
            }
            yandex.exit();
        }
Esempio n. 2
0
        public async void execute()
        {
            Yandex yandex = new Yandex();

            if (!yandex.isValidRegion())
            {
                yandex.open_settings();
            }
            yandex.change_search_pos_count();

            try
            {
                while (true)
                {
                    kwMutext.WaitOne();

                    this.offset = !settings.KeyExists("offset", SETTINGS_SECTION) ?
                                  long.Parse(settings.Write("offset", "" + offset, SETTINGS_SECTION)) :
                                  long.Parse(settings.Read("offset", SETTINGS_SECTION));

                    this.limit   = STEP;
                    this.offset += this.limit;
                    settings.Write("offset", "" + this.offset, SETTINGS_SECTION);

                    List <DBKeyword> list = this.listKeywords(offset, limit);
                    if (list == null)
                    {
                        kwMutext.ReleaseMutex();
                        break;
                    }

                    kwMutext.ReleaseMutex();

                    foreach (DBKeyword kw in list)
                    {
                        yandex.search(kw);
                        Thread.Sleep(YandexUtils.rndSleep());
                    }
                }
            }catch { }
            yandex.exit();
        }
Esempio n. 3
0
        public void open_settings()
        {
            Console.WriteLine("ENTER BLOCK: настройка региона поиска https://yandex.ru/tune/geo/?retpath=https%3A%2F%2Fwww.yandex.ru%2F%3Fdomredir%3D1&nosync=1");
            IWebElement element = null;
            Actions     actions = null;

            driver.Navigate().GoToUrl("https://yandex.ru/tune/geo/?retpath=https%3A%2F%2Fwww.yandex.ru%2F%3Fdomredir%3D1&nosync=1");
            element = driver.FindElement(By.Id("city__front-input"));
            actions = new Actions(driver);
            actions.MoveToElement(element).Click().Perform();
            element.Clear();
            element.SendKeys("Москва");
            System.Threading.Thread.Sleep(YandexUtils.rndSleep());
            element.SendKeys(Keys.Down);
            System.Threading.Thread.Sleep(YandexUtils.rndSleep());
            element.SendKeys(Keys.Enter);
            System.Threading.Thread.Sleep(YandexUtils.rndSleep());
            //element = driver.FindElement(By.CssSelector(".form__save"));
            //actions.MoveToElement(element).Click().Perform();
            Console.WriteLine("EXIT BLOCK: настройка региона поиска https://yandex.ru/tune/geo/?retpath=https%3A%2F%2Fwww.yandex.ru%2F%3Fdomredir%3D1&nosync=1");
        }
Esempio n. 4
0
        public void change_search_pos_count()
        {
            Console.WriteLine("ENTER BLOCK: установка величины поисковой выдачи https://yandex.ru/search/customize");
            driver.Navigate().GoToUrl("https://yandex.ru/search/customize");

            IWebElement element = null;
            Actions     actions = null;

            element = driver.FindElement(By.CssSelector(".fieldset:nth-of-type(1) .field__content .radio:nth-of-type(2)"));
            actions = new Actions(driver);
            actions.MoveToElement(element).Click().Perform();
            System.Threading.Thread.Sleep(YandexUtils.rndSleep());
            element = driver.FindElement(By.CssSelector(".fieldset:nth-of-type(2) .field__content .radio:nth-of-type(4)"));
            actions = new Actions(driver);
            actions.MoveToElement(element).Click().Perform();
            System.Threading.Thread.Sleep(YandexUtils.rndSleep());
            element = driver.FindElement(By.CssSelector(".form__submit button[name='save']"));
            actions = new Actions(driver);
            actions.MoveToElement(element).Click().Perform();
            System.Threading.Thread.Sleep(YandexUtils.rndSleep());
            Console.WriteLine("EXIT BLOCK: установка величины поисковой выдачи https://yandex.ru/search/customize");
        }