Exemplo 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");
        }
Exemplo n.º 2
0
        internal override void Start(int limit)
        {
            for (int j = 0; j < 5; j++)
            {
                if (!OpenRandomFollowerPage())
                {
                    return;
                }

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

                    if (IsBlock())
                    {
                        return;
                    }

                    Сhrome.Scroll(xpathNextUser);
                    if (!ParseAndFollowing(xpathNextUser, limit))
                    {
                        return;
                    }
                    // Thread.Sleep(100);
                }
                Cons.WriteLine($"___ Смена списка подписок");
            }
        }
Exemplo n.º 3
0
        internal bool IsBlock()
        {
            string xpath = $@"/html/body/div[26]/div/div[2]/a";

            if (Сhrome.IsElementPage(By.XPath(xpath)))
            {
                Cons.WriteLine($"Limit error.");
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
        internal bool OpenRandomFollowerPage()
        {
            Cons.WriteLine($"{Name}: Open Random Page.");
            Сhrome.OpenUrl(db.GetRandomUrl() + "/followers");

            if (Сhrome.FindWebElement(By.XPath(UserXpath)) == null)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 5
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();
        }
        internal override void Start(int limit)
        {
            for (int j = 0; j < 100; j++)
            {
                if (!OpenRandomFollowerPage())
                {
                    Cons.WriteLine($"Open random page error.");
                    return;
                }

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

                    if (imageAddBoard_counter >= limit)
                    {
                        return;
                    }

                    if (IsBlock())
                    {
                        return;
                    }

                    if (!Сhrome.Scroll(xpathNextUser))
                    {
                        break;
                    }

                    if (CheckUser(xpathNextUser, out string userUrl, out _, out _, out _))
                    {
                        AddImageToBoard(userUrl);
                        db.AddUser(userUrl, 0, 0, 0);
                        imageAddBoard_counter++;
                        Cons.WriteLine($"{Name}. Count = {imageAddBoard_counter}");
                    }

                    Thread.Sleep(100);
                }
                Cons.WriteLine("End following list");
            }
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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();
            }
        }
Exemplo n.º 11
0
 internal void Close()
 {
     Cons.WriteLine($"{Name}: Close.");
     Сhrome.Quit();
 }
Exemplo n.º 12
0
        internal bool CheckUser(string xpath, out string userUrl, out int userCountLike, out int userCountViews, out string userName)
        {
            string buttonText = String.Empty;
            var    element    = Сhrome.FindWebElement(By.XPath(xpath + @"/div/div/div/div[2]/div[3]/span"));

            if (element != null)
            {
                userCountLike = ParsToInt(element.Text);
            }
            else
            {
                userCountLike = 0;
            }

            element = Сhrome.FindWebElement(By.XPath(xpath + @"/div/div/div/div[2]/div[4]/span"));
            if (element != null)
            {
                userCountViews = ParsToInt(element.Text);
            }
            else
            {
                userCountViews = 0;
            }

            element = Сhrome.FindWebElement(By.XPath(xpath + @"/div/div/div/div[2]/div[1]/div/a[1]/span"));
            if (element != null)
            {
                buttonText = element.Text;
            }

            IWebElement Element = Сhrome.FindWebElement(By.XPath(xpath + @"/div/div/div/div[1]/h3/a"));

            if (Element == null)
            {
                userUrl = userName = null;
                return(false);
            }
            userUrl  = Element.GetAttribute("href");
            userName = Element.Text;

            if (db.IsRepeat(userUrl))
            {
                if (repeatCounter % 100 == 0)
                {
                    Cons.WriteLine($"{Name}:Repeat account. {repeatCounter}");
                }
                repeatCounter++;
                return(false);
            }

            if (userCountViews > 20000)
            {
                Cons.WriteLine($"{Name}:{userName} - Add for subscribe.");
                db.AddUser(userUrl, 1, 0, 0);
            }


            if (userCountLike < 200 && userCountLike > 10 && userCountViews < 900 && userCountViews > 30 && buttonText == "Подписаться на")
            {
                Thread.Sleep(500);
                return(true);
            }
            return(false);
        }