Beispiel #1
0
 private void bsl()
 {
     for (int i = 0; i < drv.FindElementsByXPath("//div[@id='row1']/span").Count; i++)
     {
         drv.FindElementByXPath("//input[@id='inputfield']").SendKeys(drv.FindElementsByXPath("//div[@id='row1']/span")[i].Text);
         drv.FindElementByXPath("//input[@id='inputfield']").SendKeys(OpenQA.Selenium.Keys.Space);
     }
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            ChromeOptions options = new ChromeOptions();

            options.AddArguments(@"user-data-dir=C:\Users\raton\AppData\Local\Google\Chrome\User Data");
            ChromeDriver driver = new ChromeDriver(options);

            driver.Navigate().GoToUrl("https://discord.com/invite/pokimane");
            System.Threading.Thread.Sleep(1000);
            driver.FindElement(By.ClassName("contents-18-Yxp")).Click();
            System.Threading.Thread.Sleep(6200);
            var captureds = driver.FindElementsByXPath("//div[@class='name-3_Dsmg overflow-WK9Ogt']");

            captureds.First(x => x.Text == "verification").Click();
            System.Threading.Thread.Sleep(1000);
            driver.SwitchTo().ActiveElement().SendKeys("!verify");
            driver.SwitchTo().ActiveElement().SendKeys(Keys.Enter);
            driver.FindElementByClassName("homeIcon-tEMBK1").Click();
            driver.FindElementByClassName("overflow-WK9Ogt").Click();
            System.Threading.Thread.Sleep(300);
            driver.SwitchTo().ActiveElement().SendKeys("dqjYN");
            driver.SwitchTo().ActiveElement().SendKeys(Keys.Enter);
            System.Threading.Thread.Sleep(300);
            driver.FindElementByClassName("wrapper-1BJsBx").Click();
            Console.WriteLine("thank you!");
            Console.WriteLine("thank you!");

            System.Threading.Thread.Sleep(30000);
            var captured = "oi";
        }
Beispiel #3
0
            /// <summary>
            /// At least 1 parameter must not be empty. Serches by Id first, then by tag, then by text. In the last case it returns the first occurence
            /// </summary>
            /// <param name="text"></param>
            /// <param name="tag"></param>
            /// <param name="id"></param>
            /// <returns></returns>
            public IWebElement FindLastOrDefaultElement(string text = "", string tag = "", string id = "")
            {
                if (id != "")
                {
                    return(ChromeDriver.FindElementById(id));
                }
                if (tag != "")
                {
                    var elems = ChromeDriver.FindElements(By.TagName(tag));
                    if (text != "")
                    {
                        return(elems.LastOrDefault(s => s.Text == text || s.Text.Trim() == text));
                    }
                    else
                    {
                        return(elems.LastOrDefault());
                    }
                }
                var texts    = ChromeDriver.FindElementsByXPath(string.Format("//*[contains(text(), '{0}')]", text));
                var lastText = texts.LastOrDefault();

                if (lastText != null)
                {
                    return(lastText);
                }
                else
                {
                    return(null);
                }
            }
Beispiel #4
0
        //Return list of chapter link in the manga
        static (List <string>, List <string>) CrawlManga(ChromeDriver driver, string url, TimeSpan ts)
        {
            List <string> listChapterlink = new List <string>();
            List <string> listChaptername = new List <string>();

            //go to home page
            driver.Navigate().GoToUrl(url);

            //Wait for loading
            //Thread.Sleep(1000);
            WaitAJAX(driver, ts);

            //Get link node
            var chapterNode = driver.FindElementsByXPath("//div[@class='chapter']/a");

            //Get the link from chapter node
            foreach (var link in chapterNode)
            {
                string chapterNumberInString = Regex.Match(link.Text, @"\d+").Value;
                bool   isChapterNumber       = int.TryParse(chapterNumberInString, out int chapterNumber);
                if (chapterNumber > 331 && isChapterNumber)
                {
                    listChapterlink.Add(link.GetAttribute("href"));
                    listChaptername.Add(chapterNumberInString);
                }
            }
            return(listChapterlink, listChaptername);
        }