コード例 #1
0
        public static IReadOnlyCollection <IWebElement> TakipEttiklerim(Bilgiler bilgi, IWebDriver driver)
        {
            driver.Navigate().GoToUrl($"https://www.instagram.com/" + bilgi.yonlenicektag);
            Thread.Sleep(7000);
            IWebElement takipEdilenButonu = driver.FindElement(By.CssSelector("#react-root > section > main > div > header > section > ul > li:nth-child(3) > a"));

            takipEdilenButonu.Click();
            Thread.Sleep(2500);
            string jsCommand = "" +
                               "sayfa = document.querySelector('.isgrP');" +
                               "sayfa.scrollTo(0,sayfa.scrollHeight);" +
                               "var sayfaSonu = sayfa.scrollHeight;" +
                               "return sayfaSonu;";

            IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
            var sayfaSonu          = Convert.ToInt32(js.ExecuteScript(jsCommand));

            while (true)
            {
                var son = sayfaSonu;
                Thread.Sleep(750);
                sayfaSonu = Convert.ToInt32(js.ExecuteScript(jsCommand));
                if (son == sayfaSonu)
                {
                    break;
                }
            }

            IReadOnlyCollection <IWebElement> follwers = driver.FindElements(By.CssSelector(".FPmhX.notranslate._0imsa"));

            return(follwers);
        }
コード例 #2
0
        public static void EtiketTakip()
        {
            var options = new OpenQA.Selenium.Chrome.ChromeOptions();

            options.BinaryLocation = @"C:\Program Files\Google\Chrome\Application\chrome.exe";
            using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options))
            {
                driver.Navigate().GoToUrl("https://www.instagram.com");
                Thread.Sleep(2000);
                IWebElement userName    = driver.FindElement(By.Name("username"));
                IWebElement password    = driver.FindElement(By.Name("password"));
                IWebElement girisbutonu = driver.FindElement(By.CssSelector(".sqdOP.L3NKy.y3zKF"));

                Bilgiler bilgi = new Bilgiler();
                bilgi.kullaniciAdi  = "";
                bilgi.sifre         = "";
                bilgi.yonlenicektag = "";

                userName.SendKeys(bilgi.kullaniciAdi);
                password.SendKeys(bilgi.sifre);
                girisbutonu.Click();
                Thread.Sleep(9000);
                var gototagurl = "https://www.instagram.com/explore/tags/" + bilgi.yonlenicektag + "/";
                driver.Navigate().GoToUrl(gototagurl);
                Thread.Sleep(3500);
                IWebElement firtpicture = driver.FindElement(By.CssSelector("._9AhH0"));
                firtpicture.Click();
                while (true)
                {
                    try
                    {
                        IWebElement prevnex = driver.FindElement(By.CssSelector("._65Bje.coreSpriteRightPaginationArrow"));
                        prevnex.Click();
                        Thread.Sleep(2500);
                        IWebElement followbtn = driver.FindElement(By.CssSelector(".sqdOP.yWX7d.y3zKF"));
                        followbtn.Click();
                        Thread.Sleep(2500);
                    }
                    catch { }
                }
                var Followbtn = driver.FindElement(By.XPath("//button[. = 'Takip Et']"));
                Followbtn.Click();
            }
        }
コード例 #3
0
        public static Bilgiler Login(IWebDriver driver)
        {
            driver.Navigate().GoToUrl("https://www.instagram.com");
            Thread.Sleep(2000);
            IWebElement userName    = driver.FindElement(By.Name("username"));
            IWebElement password    = driver.FindElement(By.Name("password"));
            IWebElement girisbutonu = driver.FindElement(By.CssSelector(".sqdOP.L3NKy.y3zKF"));
            Bilgiler    bilgi       = new Bilgiler();

            bilgi.kullaniciAdi  = "";
            bilgi.sifre         = "";
            bilgi.yonlenicektag = "";
            userName.SendKeys(bilgi.kullaniciAdi);
            password.SendKeys(bilgi.sifre);
            girisbutonu.Click();
            Thread.Sleep(7000);

            return(bilgi);
        }