Ejemplo n.º 1
0
        internal void Unsubscribe(int j)
        {
            j += 2;

            IWebElement Element = Сhrome.FindWebElement(By.XPath($"{FollowingUserXpath}/li[{j}]//div/div/div/div[1]/h3/a"));
            string      userUrl = Element.GetAttribute("href");

            Cons.WriteLine($"Unsubscribe: {j}) {userUrl}", false);
            db.UpdateUser(userUrl, 0, 1, 0);

            string btn_1 = $"{FollowingUserXpath}/li[{j}]/div/div/div/div[2]/div[1]/div/a[2]";
            string btn_2 = $"{FollowingUserXpath}/li[{j}]/div/div/div/div[2]/div[1]/div/a[3]";

            IWebElement elem_button_1 = Сhrome.FindWebElement(By.XPath(btn_1));
            IWebElement elem_button_2 = Сhrome.FindWebElement(By.XPath(btn_2));

            if (elem_button_1.Displayed)
            {
                Сhrome.ClickButtonXPath(btn_1);
                return;
            }
            if (elem_button_2.Displayed)
            {
                Сhrome.ClickButtonXPath(btn_2);
                return;
            }

            Cons.WriteLine($"Account: {j}, error unsubscribe");
        }
Ejemplo n.º 2
0
        internal override void Start(int limit)
        {
            Сhrome.OpenUrl(@"https://www.behance.net/balakir/projects");
            Thread.Sleep(TimeSpan.FromSeconds(2));

            string mySubs_xPath = "//div[@class = 'UserInfo-column-TMV']/table/tbody/tr[4]/td[2]/a";
            int    subsCount    = ParsToInt(Сhrome.FindWebElement(By.XPath(mySubs_xPath)).Text);

            Cons.WriteLine($"{Name} Number of our subscriptions {subsCount}");
            if (subsCount <= 1300)
            {
                Cons.WriteLine("The number of subscriptions is not enough to start unsubscribing.");
                return;
            }

            Сhrome.ClickButtonXPath(mySubs_xPath);
            Thread.Sleep(TimeSpan.FromSeconds(1));

            if (Сhrome.FindWebElement(By.XPath(FollowingUserXpath)) == null)
            {
                Cons.WriteLine("UserXpath not found.");
                return;
            }

            for (int i = 2; i < subsCount; i++)
            {
                Сhrome.Scroll(string.Format($"{FollowingUserXpath}/li[{i}]"));

                if (i % 100 == 0)
                {
                    Cons.WriteLine($"Scroll following list.{i}");
                }
            }

            for (int i = subsCount - 3; i > 0; i--)
            {
                if (IsBlock())
                {
                    return;
                }


                Сhrome.Scroll(string.Format($"{FollowingUserXpath}/li[{i}]"));
                Thread.Sleep(3000);
                Unsubscribe(i);
                limit--;
                if (limit <= 0)
                {
                    return;
                }
            }
        }
        private void AddImageToBoard(string userUrl)
        {
            Сhrome.OpenUrlNewTab(userUrl);
            IWebElement Element_photo = Сhrome.FindWebElement(By.XPath("//div[@class = 'e2e-Work']/div/div[1]/div[1]/div/div/div[2]/a"));

            if (Element_photo == null)
            {
                Cons.WriteLine($"AddImageToBoard. v2 {userUrl}");
                Сhrome.CloseAndReturnTab();
                return;
            }

            string url_photo = Element_photo.GetAttribute("href");

            Сhrome.OpenUrl(url_photo);

            Thread.Sleep(1000);
            if (!Сhrome.ClickButtonXPath("//div[. = 'Сохранить']"))
            {
                Cons.WriteLine($"Error open board.");
                Сhrome.CloseAndReturnTab();
                return;
            }

            Thread.Sleep(500);
            if (Сhrome.FindWebElement(By.XPath("//*[contains(text(), 'Новая доска настроени')]")) == null)
            {
                if (!Сhrome.ClickButtonXPath("//div[. = 'Сохранить']"))
                {
                    Cons.WriteLine($"Error check open board.");
                    Сhrome.CloseAndReturnTab();
                    return;
                }
            }

            Thread.Sleep(200);
            if (!Сhrome.ClickButtonXPath($"//li[. ='{GetRandomNameBoard()}']"))
            {
                Cons.WriteLine($"Error select board.");
            }

            Thread.Sleep(600);
            if (!Сhrome.ClickButtonXPath("//button[. ='Сохранить']"))
            {
                Cons.WriteLine($"Error save image to board.");
            }

            Thread.Sleep(3000);
            Сhrome.CloseAndReturnTab();
        }
Ejemplo n.º 4
0
        internal bool Autorize(string v1, string v2)
        {
            int timeSleep = 2000;

#if DEBUG
            timeSleep /= 2;
#endif
            Cons.WriteLine($"{Name}: authorization.");
            Сhrome.OpenUrl(@"https://www.behance.net/search");

            if (Сhrome.FindWebElement(By.XPath("//a[@aria-label ='Создать проект']")) != null)
            {
                Cons.WriteLine($"{Name}: authorization - ok.");
                return(true);
            }

            //---Enter---
            IWebElement Element = Сhrome.FindWebElement(By.XPath("//li/div/button[contains(.,'Вход')]"));
            Element.Click();

            Thread.Sleep(timeSleep);
            Сhrome.SendKeysXPath(".//input[@id='EmailPage-EmailField']", v1);
            Thread.Sleep(timeSleep);
            Сhrome.ClickButtonXPath(".//*[@id='EmailForm']/section[2]/div[2]/button");
            Thread.Sleep(timeSleep);
            Сhrome.SendKeysXPath(".//input[@id='PasswordPage-PasswordField']", v2);
            Thread.Sleep(timeSleep);
            Сhrome.ClickButtonXPath(".//*[@id='PasswordForm']/section[2]/div[2]/button");
            Thread.Sleep(TimeSpan.FromSeconds(7));

            Сhrome.OpenUrl(@"https://www.behance.net");
            if (Сhrome.FindWebElement(By.XPath("//*[contains(text(), 'Создать проект')]")) == null)
            {
                Cons.WriteLine($"{Name}: Error autorize.");
                return(false);
            }
            Cons.WriteLine($"{Name}: Authorized.");
            return(true);
        }
Ejemplo n.º 5
0
        internal bool ParseAndFollowing(string xpathNextUser, int follow_max_count)
        {
            if (CheckUser(xpathNextUser, out string userUrl, out int userCountLike, out int userCountViews, out string userName))
            {
                if (Сhrome.ClickButtonXPath(xpathNextUser + @"/div/div/div/div[2]/div[1]/div/a[1]"))
                {
                    Cons.WriteLine($"{Name} Follow:{folow_counter}) {userCountLike} {userCountViews} {userName} ");
                    folow_counter++;
                    db.AddUser(userUrl, 0, 0, 1);       //Add to friend
                }
                else
                {
                    Cons.WriteLine($"{Name} Error follow {userName}");
                }
                return(true);
            }

            if (folow_counter >= follow_max_count)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
        internal override void Start(int limit)
        {
            while (true)
            {
                if (!OpenRandomFollowerPage())
                {
                    return;
                }

                for (int i = 3; i < 3000; i++)
                {
                    string xpathNextUser = UserXpath + "/li[" + i + "]";

                    if (like_counter >= limit)
                    {
                        return;
                    }

                    if (IsBlock())
                    {
                        return;
                    }

                    if (!Сhrome.Scroll(xpathNextUser))
                    {
                        break;
                    }
                    if (CheckUser(xpathNextUser, out string userUrl, out _, out _, out _))
                    {
                        if (userUrl == null)
                        {
                            continue;
                        }

                        LikePhoto(userUrl);
                        like_counter++;
                        Cons.WriteLine($"Like!#{like_counter}");
                        db.AddUser(userUrl, 0, 0, 0);
                    }
                }
                Cons.WriteLine("End following list");
            }


            void LikePhoto(string userUrl)
            {
                if (userUrl == null)
                {
                    return;
                }


                Сhrome.OpenUrlNewTab(userUrl);

                IWebElement Element_photo = Сhrome.FindWebElement(By.XPath(@"//*[@id='site-content']/div/main/div[2]/div[2]/div/div/div/div/div[1]/div[1]/div/div/div[2]/a"));

                if (Element_photo == null)
                {
                    Thread.Sleep(3000);
                    Сhrome.CloseAndReturnTab();
                    return;
                }

                Сhrome.OpenUrl(Element_photo.GetAttribute("href"));
                Thread.Sleep(300);

                if (!Сhrome.ClickButtonXPath(@"//div[.='Оценить']"))
                {
                    Cons.WriteLine($"Error like!");
                }

                Thread.Sleep(1000);
                Сhrome.CloseAndReturnTab();
            }
        }