title: Loop through rows to get column data using selenium and python
body: <p>I'm trying to use Python 3.6 and Selenium to grab data form a table. One of the tables I'm trying to grab from has multiple rows. So, I want to get column 9 from each row. </p>
  
  <p>I searched around on this site and found some code that I was able to adapt to almost work. </p>
  
  <pre><code>table_id = driver.find_element(By.ID, 'ctl00_mid_rptItems_ctl00_gvItems')
  rows = table_id.find_elements(By.TAG_NAME, "tr")
  for row in rows:
      cols = row.find_elements(By.TAG_NAME, "td")  
      for col in cols:
          print (cols[8].text)
  </code></pre>
  
  <p>It spits out the correct data from the column I want, but the problem I'm having is that it loops through each row 16 times, which is the number of columns in the table, and prints each data point 16 times. </p>
  
  <p>I tried to adapt the code above to just spit out each column 1 time by removing the "for col" loop</p>
  
  <pre><code>table_id = driver.find_element(By.ID, 'ctl00_mid_rptItems_ctl00_gvItems')
  rows = table_id.find_elements(By.TAG_NAME, "tr")
  for row in rows:
      cols = row.find_elements(By.TAG_NAME, "td")
      print (cols[8].text)
  </code></pre>
  
  <p>But, this gives the the error "Traceback (most recent call last): 
  File "C:\Users\Documents\PleaseTest_R1.py", line 91, in <br>
  print (cols[8].text)
  IndexError: list index out of range</p>
  
  <p>Any ideas on how I can get this loop to work?<br>
  Thanks so much for the help! :-)</p>