title: Trying to fetch option chain data from NSE... but getting error using Chromedriver
body: <p>Below is the code through which I am trying to fetch option chain data but I am getting errors.
  Any help will be appreciated.
  Thanks</p>
  <p>Also, if someone can help me with a better code to record tick data, that would be great</p>
  <pre><code>import time
  import datetime
  import pandas as pd
  from bs4 import BeautifulSoup,SoupStrainer
  from selenium import webdriver
  from selenium.webdriver.chrome.options import Options
  # from selenium.webdriver import Chrome as uc
  
  # options=chrome_options
  
  df=pd.DataFrame(columns=['SNO','call OI','call CHNG IN OI','call VOLUME','call IV','call LTP','call CHNG','call BID QTY','call BID PRICE','call ASK PRICE','call ASK QTY','STRIKE PRICE','put BID QTY','put BID PRICE','put ASK PRICE','put ASK QTY','put CHNG','put LTP','put IV','put VOLUME','put CHNG IN OI','put OI'])
  
  
  chrome_options = Options()
  chrome_options.add_argument(&quot;--log-level=3&quot;)
  from selenium.webdriver import Chrome as uc
  chrome_options = uc.ChromeOptions()  #new solution
  chrome_options.add_argument('--headless')
  driver = webdriver.Chrome(executable_path=r&quot;C:\Users\rohit taparia\Downloads\chromedriver_win32\chromedriver.exe&quot;,options=chrome_options)
  
  driver.get('https://www.nseindia.com/get-quotes/derivatives?symbol=BANKNIFTY')
  
  driver.minimize_window()
  time.sleep(3)
  
  for j in range(0,50):
      print(j)
  #.....refresh the page and read data again 
  
      driver.refresh()
      continue_link1 = driver.find_element_by_xpath('''//*[@id=&quot;subtab-derivatives&quot;]/div[2]/nav/div/div/a[2]''')
      time.sleep(10)
      filter_tag=SoupStrainer(&quot;table&quot;)
  
      continue_link1.click()
      time.sleep(3)
      rtime = str(driver.find_element_by_xpath('''//*[@id=&quot;asondate&quot;]''').text)
      if rtime=='':
          continue
      print(rtime)
      page=driver.page_source
      soup = BeautifulSoup(page, &quot;html.parser&quot;,parse_only=filter_tag)
  
      gdp_table = soup.find(&quot;table&quot;, attrs={&quot;id&quot;: &quot;optionChainTable-indices&quot;})
      gdp_table_data = gdp_table.tbody.find_all(&quot;tr&quot;)
      
      if len(gdp_table_data)==1:
          continue
      else:
          for i in range (0,len(gdp_table_data)):
              list1 = []
              for td in gdp_table_data[i].find_all(&quot;td&quot;):
                  # remove any newlines and extra spaces from left and right
                  cell_text=td.text
                  if cell_text is None or cell_text=='':
                      cell_text ='0'
                  cell_text=cell_text.replace(',','')
                  list1.append(cell_text)
  
              if len(list1) &gt; 0:
                  list1 = ['0' if i=='-' else i for i in list1]
              else:
                  continue       
              del list1[0]
              del list1[-1]
  
              list1 = list(map(float, list1))
              list1.insert(0,rtime)   
              df.loc[len(df)] = list1
  
  df.to_excel(&quot;option-data.xlsx&quot;)
  </code></pre>