title: Skip selenium Webdriver.get() call inside for loop if it takes too long
body: <p>Hey guys I'm having trouble understanding how can I add exceptions to a for in range loop. Right now I'm pulling URLs from an excel sheet and scraping the information while moving throughout the pages until I reach page 200. The thing is that not all URLs have pages up to 200 so It's taking a lot of time until the loop ends and program can continue with another URL. Is there a way to implement exceptions in to the code here?</p>
  <pre class="lang-py prettyprint-override"><code>from selenium import webdriver
  import pandas as pd
  import time
  
  driver = webdriver.Chrome(&quot;C:/Users/Acer/Desktop/chromedriver.exe&quot;)
  
  companies = []
  
  df = pd.read_excel('C:/Users/Acer/Desktop/urls.xlsx')
  
  for index, row in df.iterrows():
      base_url = (row['urls'])
      
      for i in range(1,201,1):
          
          url = &quot;{base_url}?curpage={i}&quot;.format(base_url=base_url, i=i)
          driver.get(url)
          time.sleep(2)
          
          name = driver.find_elements_by_xpath('//a/div/div/p')
      
          for names in name:
              print(names.text, url)
              companies.append([names.text, url])
  </code></pre>