title: Grabbing data from td tags with python and beautifulsoup
body: <p>I'm a beginner with Python and am working through some tasks with data I'm familiar with to learn the basics. I'm trying to crawl through a table to gather contact information but having issues getting at the data in a list of tds.</p>
  
  <p>The HTML looks like this:</p>
  
  <pre><code>&lt;table class="table table-striped" data-drupal-selector="edit-directory" id="edit-directory--zJwP9mT4moQ"&gt;
     &lt;thead&gt;
     &lt;tr&gt;
         &lt;th&gt;Name&lt;/th&gt;
         &lt;th&gt;Job Title&lt;/th&gt;
         &lt;th&gt;Campus/Department&lt;/th&gt;
         &lt;th&gt;Contact&lt;/th&gt;
     &lt;/tr&gt;
     &lt;/thead&gt;
     &lt;tbody&gt;
     &lt;tr class="odd"&gt;
         &lt;td&gt;LAST, FIRST&lt;/td&gt;
         &lt;td&gt;T-HS SCI- GEN'L&lt;/td&gt;
         &lt;td&gt;&lt;span tabindex="0"&gt;SCHOOL&lt;/span&gt;&lt;/td&gt;
         &lt;td&gt;&lt;a href="mailto:teacher@school.org" class="email"&gt;&lt;span aria-hidden="true"&gt;Email&lt;/span&gt;&lt;span class="sr-only"&gt;teacher@school.org&lt;/span&gt;&lt;/a&gt;&lt;br&gt;555-555-5555&lt;/td&gt;
     &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I have this code to get the table</p>
  
  <pre><code>data = urllib.parse.urlencode(params).encode("utf-8")
      req = urllib.request.Request(url)
      with urllib.request.urlopen(req,data=data) as f:
          soup = bs(f, 'html.parser')
  
  table = soup.find("table")
  
  for row in table.findAll("tr"):
          #print (row)
          cells = row.findAll("td")
          print(cells) 
  </code></pre>
  
  <p>I get something like this:</p>
  
  <pre><code>[&lt;td&gt;LAST,FIRST &lt;/td&gt;, &lt;td&gt;TEMP PROF&lt;/td&gt;, &lt;td&gt;&lt;span tabindex="0"&gt;SCHOOL&lt;/span&gt;&lt;/td&gt;, &lt;td&gt;&lt;a class="email" href="mailto:teacher@school.org"&gt;&lt;span aria-hidden="true"&gt;Email&lt;/span&gt;&lt;span class="sr-only"&gt;teacher@school.org&lt;/span&gt;&lt;/a&gt;&lt;br/&gt;555-555-5555&lt;/td&gt;]
  
  [&lt;td&gt;&lt;a href="https://teachersite.com" target="_blank"&gt;LAST, FIRST&lt;/a&gt;&lt;/td&gt;, &lt;td&gt;T-ENGLISH&lt;/td&gt;, &lt;td&gt;&lt;span tabindex="0"&gt;SCHOOL&lt;/span&gt;&lt;/td&gt;, &lt;td&gt;&lt;a class="email" href="mailto:teacher@school.org"&gt;&lt;span aria-hidden="true"&gt;Email&lt;/span&gt;&lt;span class="sr-only"&gt;teacher@school.org/span&gt;&lt;/a&gt;&lt;br/&gt;555-555-5555&lt;/td&gt;]
  </code></pre>
  
  <p>But if I try to then get at the data in the list:</p>
  
  <pre><code>print (cells[1]) 
  </code></pre>
  
  <p>It says the index is out of range</p>
  
  <p>What I'm trying to get is something like this:</p>
  
  <pre><code>last = 'LAST'
  first = 'FIRST'
  email = 'teacher@school.com'
  title = 'TEMP PROF'
  phone = '555-555-5555'
  </code></pre>