Esempio n. 1
0
        private void _postSlando( Advert adv )
        {
            slando_driver.Navigate().GoToUrl("http://www.slando.ru/post-new-ad/");
            slando_driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

            slando_driver.FindElement(By.Id("add-title")).Clear();
            slando_driver.FindElement(By.Id("add-title")).SendKeys(adv.name);
            slando_driver.FindElement(By.XPath("//span[@id='choose-category-button']")).Click();
            Delay(1);
            slando_driver.FindElement(By.LinkText("Недвижимость")).Click();
            Delay(1);
            slando_driver.FindElement(By.LinkText("Аренда квартир")).Click();
            Delay(1);
            slando_driver.FindElement(By.LinkText("Долгосрочная аренда квартир")).Click();
            new SelectElement(slando_driver.FindElement(By.Id("id-offer-seek"))).SelectByText("Предлагаю");
            slando_driver.FindElement(By.Name("data[param_price][1]")).Clear();
            slando_driver.FindElement(By.Name("data[param_price][1]")).SendKeys(adv.price);
            slando_driver.FindElement(By.Name("data[param_number_of_rooms]")).Clear();
            slando_driver.FindElement(By.Name("data[param_number_of_rooms]")).SendKeys(adv.roomNumber);
            slando_driver.FindElement(By.Name("data[param_rent_from]")).Click();
            slando_driver.FindElement(By.Name("data[param_rent_from]")).Clear();
            slando_driver.FindElement(By.Name("data[param_rent_from]")).SendKeys(adv.date);
            slando_driver.FindElement(By.Id("parameter-div-number_of_rooms")).Click();
            new SelectElement(slando_driver.FindElement(By.Id("id_private_business"))).SelectByText("Частное лицо");
            slando_driver.FindElement(By.Id("add-description")).Clear();
            slando_driver.FindElement(By.Id("add-description")).SendKeys(adv.desc);
            slando_driver.FindElement(By.Id("show-gallery-html")).Click();
            new SelectElement(slando_driver.FindElement(By.Id("region-id-select"))).SelectByText(" -> Санкт-Петербург");
            slando_driver.FindElement(By.Id("add-person")).Clear();
            slando_driver.FindElement(By.Id("add-person")).SendKeys(adv.person);
            slando_driver.FindElement(By.Id("add-phone")).Clear();
            slando_driver.FindElement(By.Id("add-phone")).SendKeys(adv.phone);
            slando_driver.FindElement(By.Id("save")).Click();
        }
Esempio n. 2
0
 public void parse(String buf, Advert ad)
 {
 }
Esempio n. 3
0
        private bool _postRestate( Advert adv )
        {
            restate_driver.Navigate().GoToUrl("http://www.restate.ru/add.html");
            restate_driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

            new SelectElement(restate_driver.FindElement(By.Id("object_deal_id"))).SelectByText("Сдать в аренду");
            new SelectElement(restate_driver.FindElement(By.Id("object_area_id"))).SelectByText(adv.district + " р-н");
            new SelectElement(restate_driver.FindElement(By.Id("object_metro_id"))).SelectByText(adv.subway_station);
            restate_driver.FindElement(By.Id("object_address_street1")).Clear();
            restate_driver.FindElement(By.Id("object_address_street1")).SendKeys(adv.street);
            restate_driver.FindElement(By.Id("house")).Clear();
            restate_driver.FindElement(By.Id("house")).SendKeys(adv.house);
            restate_driver.FindElement(By.Id("sall")).Clear();
            restate_driver.FindElement(By.Id("sall")).SendKeys(adv.square);
            restate_driver.FindElement(By.Id("description")).Clear();
            restate_driver.FindElement(By.Id("description")).SendKeys(adv.desc);
            restate_driver.FindElement(By.Id("price")).Clear();
            restate_driver.FindElement(By.Id("price")).SendKeys(adv.price);
            restate_driver.FindElement(By.Id("contacts")).Clear();
            restate_driver.FindElement(By.Id("contacts")).SendKeys(adv.phone + "\n" + adv.e_mail);
            restate_driver.FindElement(By.Name("commit")).Click();

            restate_driver.FindElement(By.Id("rooms")).Clear();
            restate_driver.FindElement(By.Id("rooms")).SendKeys(adv.roomNumber);
            restate_driver.FindElement(By.Id("et")).Clear();
            restate_driver.FindElement(By.Id("et")).SendKeys(adv.floor);
            restate_driver.FindElement(By.Id("etall")).Clear();
            restate_driver.FindElement(By.Id("etall")).SendKeys(adv.floorNumber);
            restate_driver.FindElement(By.Id("s1")).Clear();
            restate_driver.FindElement(By.Id("s1")).SendKeys(adv.square);
            restate_driver.FindElement(By.Name("commit")).Click();

            return true;
        }
Esempio n. 4
0
        private bool _postOlx( Advert adv )
        {
            olx_driver.Navigate().GoToUrl("http://www.olx.ru/posting.php");
            olx_driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

            olx_driver.FindElement(By.Id("regionSelectorChangeMode")).Click();
            Delay(2);
            new SelectElement(olx_driver.FindElement(By.Id("state"))).SelectByText("Санкт-Петербург");
            new SelectElement(olx_driver.FindElement(By.Id("city"))).SelectByText("Санкт-Петербург");
            new SelectElement(olx_driver.FindElement(By.Id("categoryParent"))).SelectByText("Недвижимость");
            new SelectElement(olx_driver.FindElement(By.Id("categoryChild"))).SelectByText("Аренда квартир, домов");
            olx_driver.FindElement(By.Id("title")).Clear();
            olx_driver.FindElement(By.Id("title")).SendKeys(adv.name);
            olx_driver.FindElement(By.Id("C")).Clear();
            olx_driver.FindElement(By.Id("C")).SendKeys(adv.price);
            olx_driver.FindElement(By.Id("email")).Clear();
            olx_driver.FindElement(By.Id("email")).SendKeys(adv.e_mail);
            olx_driver.FindElement(By.Id("phone")).Clear();
            olx_driver.FindElement(By.Id("phone")).SendKeys(adv.phone);
            olx_driver.FindElement(By.Id("surface")).Clear();
            olx_driver.FindElement(By.Id("surface")).SendKeys(adv.square);
            olx_driver.FindElement(By.Id("streetaddress")).Clear();
            olx_driver.FindElement(By.Id("streetaddress")).SendKeys(adv.street + ", " + adv.house);
            new SelectElement(olx_driver.FindElement(By.Id("bedrooms"))).SelectByText(adv.roomNumber);
            new SelectElement(olx_driver.FindElement(By.Id("neighborhood"))).SelectByText(adv.subway_station);

            olx_driver.FindElement(By.Id("description_ifr")).SendKeys(adv.desc);

            olx_driver.FindElement(By.Id("btnPublish")).Click();

            Delay(3);

            if (olx_driver.Url == "http://www.olx.ru/posting_success.php")
                return true;
            else
                return false;
        }
Esempio n. 5
0
        private void _postAvito( Advert adv )
        {
            avito_driver.Navigate().GoToUrl("http://www.avito.ru/additem");
            avito_driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

            avito_driver.FindElement(By.Id("fld_phone")).Clear();
            avito_driver.FindElement(By.Id("fld_phone")).SendKeys(adv.phone);
            new SelectElement(avito_driver.FindElement(By.Id("region"))).SelectByText("-- Выберите город --");
            avito_driver.FindElement(By.Id("select-region")).Click();
            avito_driver.FindElement(By.CssSelector("#location_653240 > strong")).Click();
            new SelectElement(avito_driver.FindElement(By.Id("fld_metro_id"))).SelectByText(adv.subway_station);
            new SelectElement(avito_driver.FindElement(By.Id("fld_category_id"))).SelectByText("Квартиры");
            new SelectElement(avito_driver.FindElement(By.Id("flt_param_201"))).SelectByText("Сдам");
            new SelectElement(avito_driver.FindElement(By.Id("flt_param_550"))).SelectByText(adv.roomNumber);
            new SelectElement(avito_driver.FindElement(By.Id("flt_param_504"))).SelectByText("На длительный срок");
            new SelectElement(avito_driver.FindElement(By.Id("flt_param_501"))).SelectByText(adv.floor);
            new SelectElement(avito_driver.FindElement(By.Id("flt_param_502"))).SelectByText(adv.floorNumber);
            avito_driver.FindElement(By.Id("flt_param_500")).Clear();
            avito_driver.FindElement(By.Id("flt_param_500")).SendKeys(adv.square);
            avito_driver.FindElement(By.Id("flt_param_493")).Clear();
            avito_driver.FindElement(By.Id("flt_param_493")).SendKeys(adv.street + ", " + adv.house);
            avito_driver.FindElement(By.Id("fld_title")).Clear();
            avito_driver.FindElement(By.Id("fld_title")).SendKeys(adv.name);
            avito_driver.FindElement(By.Id("fld_description")).Clear();
            avito_driver.FindElement(By.Id("fld_description")).SendKeys(adv.desc);
            avito_driver.FindElement(By.Id("fld_price")).Clear();
            avito_driver.FindElement(By.Id("fld_price")).SendKeys(adv.price);
            avito_driver.FindElement(By.Id("form_submit")).Click();
        }
Esempio n. 6
0
 public void postAdvert( Advert adv )
 {
     if (_postOlx(adv))
         ;
     if (_postRestate(adv))
         ;
     _postAvito(adv);
     _postSlando(adv);
 }
Esempio n. 7
0
        public static bool work( SeleniumPoster ps, Server s )
        {
            int length = -1;
            byte[] buf = new byte[4096];
            bool loginCaught = false, passCaught = false;
            String captchakey, pass = "******", login = "******", advert;

            try
            {

                while (true)
                {
                    int res = s.receiveMessage(buf, ref length);

                    if (res == 3) // captchakey
                    {
                        System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                        captchakey = enc.GetString(buf, 0, length);

                        ps.setCaptchaKey(captchakey);
                        Console.WriteLine("captchakey set: " + captchakey + " verifying");
                        if (ps.verifyCaptchaKey())
                            s.sendResult(true);
                        else
                            s.sendResult(false);
                    }

                    if (res == 1) // password
                    {
                        passCaught = true;
                        System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                        pass = enc.GetString(buf, 0, length);

                        Console.WriteLine("pass: "******"login: " + login);
                    }

                    if (res == 0) // advert
                    {
                        System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                        advert = enc.GetString(buf, 0, length);

                        string[] words = advert.Split('\n');

                        /*        public Advert( string roomNumber,
                       string price,
                       string name,
                       string desc,
                       string district,
                       string subway_station,
                       string street,
                       string house,
                       string square,
                       string floor,
                       string floorNumber,
                       string phone,
                       string e_mail,
                       string person,
                       string date )*/

                        Advert adv = new Advert(words[0], words[1], words[2],
                                                words[3], words[4], words[5],
                                                words[6], words[7], words[8],
                                                words[9], words[10], words[11],
                                                words[12], words[13], words[14]);

                        ps.postAdvert(adv);

                    }

                    if (loginCaught && passCaught)
                    {
                        ps.login(login, pass);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return false;
            }

            return true;
        }