var options = new ChromeOptions(); options.AddArguments("--disable-gpu");
var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
var dr = new ChromeDriver(driverService, options);
for (int d = 0; d < listBox1.Items.Count; d++) {
dr.Navigate().GoToUrl("https://www.instagram.com/" + listBox1.Items[d].ToString());
var number = dr.FindElementByClassName("_fd86t").Text; Thread.Sleep(100);
dr.FindElementByClassName("_si7dy").Click();
for (int s = 0; s < Convert.ToInt32(numericUpDown1.Value); s++) {
Thread.Sleep(1000);
if (dr.FindElements(By.XPath("/html/body/div[4]/div/div[2]/div/article/div[1]/div/div/div/div[2]/a")).Count != 0) {
dr.Keyboard.SendKeys(OpenQA.Selenium.Keys.Right); }
else {
var src = dr.FindElementByClassName("_2di5p").GetAttribute("src");
var pra = dr.FindElementByClassName("_ezgzd").FindElement(By.TagName("span")).Text;
this.Invoke(new MethodInvoker(delegate () {
dataGridView1.Rows.Add(src.ToString(), pra.ToString()); }));
dr.Keyboard.SendKeys(OpenQA.Selenium.Keys.Right); } } }