Example #1
0
        void func(object list_params)//Функция потока, передаем параметр
        {
            int limit  = ((List <int>)list_params)[0];
            int offset = ((List <int>)list_params)[1];

            try
            {
                DBConection db    = new DBConection();
                int         count = db.count();

                Google google = new Google("http://google.ru", MODE);
                while (offset < count)
                {
                    foreach (DBKeyword k in db.list(offset, limit))
                    {
                        Console.WriteLine("Выбираем словосочетание из БД="
                                          + k.keyword + "[" + k.keyword_id + "] offset="
                                          + offset + " limit=" + limit);

                        Console.WriteLine("Обращаемся к гуглу");
                        //открываем настройки и ставим регион
                        google.open_settings();
                        //тут выбираем из базы слова и в цикле по очереди вызываем метод поиска
                        google.search(k.keyword, k.keyword_id);
                    }
                    offset += STEP;
                    MyIni.Write("offset_google_" + this.threadId, "" + offset);
                }
                google.exit();
            }
            catch {}
        }
Example #2
0
        void func(object list_params)//Функция потока, передаем параметр
        {
            int limit  = ((List <int>)list_params)[0];
            int offset = ((List <int>)list_params)[1];

            try
            {
                //mut.WaitOne();
                DBConection db    = new DBConection();
                int         count = db.count();


                Yandex yandex = new Yandex("https://yandex.ru", MODE);
                if (!yandex.isValidRegion("Москва"))
                {
                    yandex.open_settings();
                }

                yandex.change_search_pos_count();

                // mut.ReleaseMutex();

                while (offset < count)
                {
                    foreach (DBKeyword k in db.list(offset, limit))
                    {
                        Console.WriteLine("Выбираем словосочетание из БД="
                                          + k.keyword + "[" + k.keyword_id + "] offset="
                                          + offset + " limit=" + limit);
                        Console.WriteLine("Обращаемся к яндексу");
                        //тут выбираем из базы слова и в цикле по очереди вызываем метод поиска
                        // mut.WaitOne();
                        yandex.search(k.keyword, k.keyword_id);
                        // mut.ReleaseMutex();
                    }

                    offset += STEP;
                    MyIni.Write("offset_yandex_" + this.threadId, "" + offset);
                }
                yandex.exit();
            }
            catch
            {
            }
        }