public void Parsing() { try { var elements = (new WebDriverWait(driver, timeout)).Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.TagName("a"))); EAct act = new EAct(driver, Project); act.Action(); for (int i = 0; i <= elements.Count; i++) { try { var collections = elements[i].GetAttribute("href"); foreach (string s in arr) { if (collections.IndexOf(s) != -1) { collections = collections.Remove(collections.IndexOf(s)); } } if (collections.StartsWith(URL) == true && urls.Contains(collections) == false) { urls.Add(collections); } } catch (ArgumentOutOfRangeException) { Action(); } catch (NullReferenceException) { Action(); } catch (StackOverflowException) { driver.Close(); driver = new EdgeDriver(@"C:\Users\r.merikanov\Downloads"); Action(); } } } catch (NoSuchElementException) { Action(); } catch (WebDriverTimeoutException) { Action(); } catch (WebDriverException) { driver.Quit(); } }
static void Main(string[] args) { Project = "Туров"; URL = "https://turovart.com/ar/"; sURL = ""; ChromePars(); FirefoxPars(); IEPars(); //EdgePars(); void EdgePars() { using (var driver = new EdgeDriver(@"C:\Users\r.merikanov\Downloads")) { EAct act = new EAct(driver, Project); act.Dir(); EParser pars = new EParser(driver, Project, URL, sURL); pars.GoUrl(); pars.Parsing(); } } void ChromePars() { ChromeOptions co = new ChromeOptions(); co.AddExtension(@"C:\Users\Adblocker-Genesis-Plus_v1.0.6.crx"); using (var driver = new ChromeDriver(co)) { Act act = new Act(driver, Project); act.Dir(); Parser pars = new Parser(driver, Project, URL, sURL); pars.GoUrl(); pars.Parsing(); } } void FirefoxPars() { using (var driver = new FirefoxDriver()) { Fact act = new Fact(driver, Project); act.Dir(); FParser pars = new FParser(driver, Project, URL, sURL); pars.GoUrl(); pars.Parsing(); } } void IEPars() { using (var driver = new InternetExplorerDriver()) { IEact act = new IEact(driver, Project); act.Dir(); IEParser pars = new IEParser(driver, Project, URL, sURL); pars.GoUrl(); pars.Parsing(); } } }