コード例 #1
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($"___ Смена списка подписок");
            }
        }
コード例 #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;
                }
            }
        }
コード例 #3
0
        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");
            }
        }
コード例 #4
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();
            }
        }