title: Python Selenium Copy Table Columns by Column Name
body: <p>I have a table that has these headers, like this:<a href="https://i.stack.imgur.com/o3amk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o3amk.png" alt="Table with Column Headings"></a></p>
  
  <p>How would I select the whole column using xpath to store in an array.
  I was hoping for different arrays, like:</p>
  
  <pre><code>courses = []
  teacher = []
  avg = []
  </code></pre>
  
  <p>Bare in mind these column don't have any ID's or classes, so I need a way to select just by using the name of the column.</p>
  
  <p>Here is the code for the table:</p>
  
  <pre><code>&lt;table border="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td nowrap="nowrap"&gt;Courses&lt;/td&gt;
  &lt;td nowrap="nowrap"&gt;Teacher&lt;/td&gt;
  &lt;td&gt;&lt;select name="fldMarkingPeriod" onchange="switchMarkingPeriod(this.value);"&gt;
  &lt;option value="MP1"&gt;MP1&lt;/option&gt;
  &lt;option selected="selected" value="MP2"&gt;MP2&lt;/option&gt;
  &lt;option value="MP3"&gt;MP3&lt;/option&gt;
  &lt;/select&gt;Avg&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td nowrap="nowrap"&gt;[Course Name]&lt;/td&gt;
  &lt;td nowrap="nowrap"&gt;[Teacher Name]&lt;/td&gt;
  &lt;td&gt;
  &lt;table width="100%" cellspacing="0" cellpadding="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td title="View Course Summary" width="70%"&gt;100%&lt;/td&gt;
  &lt;td width="30%"&gt;A+&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td nowrap="nowrap"&gt;[Course Name]&lt;/td&gt;
  &lt;td nowrap="nowrap"&gt;[Teacher Name]&lt;/td&gt;
  &lt;td&gt;
  &lt;table width="100%" cellspacing="0" cellpadding="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td title="View Course Summary" width="70%"&gt;100%&lt;/td&gt;
  &lt;td width="30%"&gt;A+&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td nowrap="nowrap"&gt;[Course Name]&lt;/td&gt;
  &lt;td nowrap="nowrap"&gt;[Teacher Name]&lt;/td&gt;
  &lt;td&gt;
  &lt;table width="100%" cellspacing="0" cellpadding="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td title="View Course Summary" width="70%"&gt;100%&lt;/td&gt;
  &lt;td width="30%"&gt;A+&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Any ideas? Thanks.</p>