title: Can't parse a second table with beautifulsoup even if the first one works?
body: <p>I am trying to parse tables using beautifulsoup. The first one on my page was easy but I cannot parse a similar table on the same page. I do not understand why.</p>
  
  <p>Here is the code. Thanks in advance for your help.</p>
  
  <pre><code>import urllib2
  from bs4 import BeautifulSoup
  
  
  url = urllib2.urlopen("https://dl.dropboxusercontent.com/u/956261/poftext.html")
  contentHTML = url.read()
  
  soup = BeautifulSoup(contentHTML)
  
  tableUserDetails = soup.find("table", {"class" : "user-details"})
  
  i = 0
  tableUserDetailsList = []
  for row in tableUserDetails.findAll('tr'):
      for col in row.findAll('td'):
          contentTd = col.contents[0].string.strip()
  
          if contentTd:
              print "TD Number %d : %s" % (i, contentTd)
              tableUserDetailsList.append(contentTd)
              i += 1
  
  # This first table is OK
  print tableUserDetailsList
  
  
  # But now this one
  tableUserDetails = soup.find("table", {"class" : "secondpart"})
  
  i = 0
  tableUserDetailsList = []
  for row in tableUserDetails.findAll('tr'):
      for col in row.findAll('td'):
          contentTd = col.contents[0].string.strip()
  
          if contentTd:
              print "TD Number %d : %s" % (i, contentTd)
              tableUserDetailsList.append(contentTd)
              i += 1
  
  print tableUserDetailsList
  
  # The list is empty :(
  </code></pre>
  
  <p>Here is a simplified version of the HTML code that I am trying to parse:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
      &lt;title&gt;
          French.Kiss
          Sorties, Sport, Voyages, Nouvelles Expériences&lt;/title&gt; 
  
  &lt;/head&gt;
  &lt;body style='background-color: #fff;' leftMargin='0' topMargin='0' marginwidth='0' marginheight='0' link='#1E55D6' vlink='#1E55D6'  TEXT='#6551b0'&gt;
  
              &lt;table class="user-details"&gt;
                  &lt;tr&gt;
                      &lt;td class="headline txtBlue size15" style="width:80px"&gt;
                          About
                      &lt;/td&gt;
                      &lt;td style="width:10px"&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          Fume occasionnellement with Silhouette mince
                      &lt;/td&gt;
                      &lt;td width="25px;"&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td class="headline txtBlue size15"&gt;
                          City
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          Paris Ile-de-France
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td class="headline txtBlue size15"&gt;
                          Details
                      &lt;/td&gt;
                      &lt;td style="width:10px"&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          26 year old Un homme, 185cm, Sans religion
                      &lt;/td&gt;
                      &lt;td&gt;
                      &lt;/td&gt;
                      &lt;td class="headline txtBlue size15"&gt;
                          Ethnicity
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          Caucasienne Balance with Châtains
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td class="headline txtBlue size15"&gt;
                          Intent
                      &lt;/td&gt;
                      &lt;td style="width:10px"&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          French.Kiss Cherche une relation amoureuse.
                      &lt;/td&gt;
                      &lt;td&gt;
                      &lt;/td&gt;
                      &lt;td class="headline txtBlue size15" style="width:90px"&gt;
                          Education
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          Diplôme universitaire/Licence
                      &lt;/td&gt;
                  &lt;/tr&gt;
  
                  &lt;tr&gt;
                      &lt;td class="headline txtBlue size15"&gt;
                          Personnalité
                      &lt;/td&gt;
                      &lt;td style="width:10px"&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
  
                      &lt;/td&gt;   &lt;td&gt;
                      &lt;/td&gt;
                  &lt;td&gt;
                              &lt;span class="headline txtBlue size15"&gt;Profession &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size15"&gt;
                                  Visioconférence&lt;/span&gt;
                          &lt;/td&gt;
                  &lt;/tr&gt;
  
              &lt;/table&gt; 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
                  &lt;table width="85%" class="secondpart"&gt;
                      &lt;tr height="25px"&gt;
                          &lt;td width="200px"&gt;
                              &lt;span class="headline txtBlue size14"&gt;I am Seeking a&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td width="300px"&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Une femme&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td width="25px"&gt;
                          &lt;/td&gt;
                          &lt;td width="200px"&gt;
                              &lt;span class="headline txtBlue size14"&gt;For&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td width="200px"&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Sorties&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;&lt;a href='needs_test.aspx'&gt;Needs Test&lt;/a&gt;&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;&lt;a href='needs_test.aspx'&gt;
  
  
                                  &lt;a href="needs_view.aspx?id=38028200"&gt;View
                                      his
                                      relationship needs&lt;/a&gt;&lt;/a&gt;&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;&lt;a href='poftest.aspx'&gt;Chemistry&lt;/a&gt;&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;&lt;a href='poftest.aspx'&gt;
  
                                  &lt;a href="personality.aspx?id=26&amp;user_id=41724176" rel="nofollow"&gt;View
                                      his
                                      chemistry results&lt;/a&gt;&lt;/a&gt;&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Do you drink?&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Occasionnellement&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Do you want children?&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Non divulgué&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Marital Status&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Célibataire&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Do you do drugs?&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Non&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Pets &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Aucun&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Eye Color&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Bruns&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Do you have a car? &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  N/A&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Do you have children?&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Non&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                           &lt;span class="headline txtBlue size14"&gt;Longest Relationship&lt;/span&gt;
                          &lt;/td&gt;
  
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Plus de 2 ans&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
  
                          &lt;/td&gt;
                          &lt;td&gt;
  
                          &lt;/td&gt;
                      &lt;/tr&gt;
  
                  &lt;/table&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>tableUserDetails.content, tableUserDetails and tableUserDetailsList for both tables:</p>
  
  <p><strong>* FIRST TABLE *</strong></p>
  
  <p>print tableUserDetails.content = none</p>
  
  <p>print tableUserDetails =</p>
  
  <pre><code>  &lt;table class="user-details"&gt;
                  &lt;tr&gt;
                      &lt;td class="headline txtBlue size15" style="width:80px"&gt;
                          About
                      &lt;/td&gt;
                      &lt;td style="width:10px"&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          Fume occasionnellement with Silhouette mince
                      &lt;/td&gt;
                      &lt;td width="25px;"&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td class="headline txtBlue size15"&gt;
                          City
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          Paris Ile-de-France
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td class="headline txtBlue size15"&gt;
                          Details
                      &lt;/td&gt;
                      &lt;td style="width:10px"&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          26 year old Un homme, 185cm, Sans religion
                      &lt;/td&gt;
                      &lt;td&gt;
                      &lt;/td&gt;
                      &lt;td class="headline txtBlue size15"&gt;
                          Ethnicity
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          Caucasienne Balance with Châtains
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td class="headline txtBlue size15"&gt;
                          Intent
                      &lt;/td&gt;
                      &lt;td style="width:10px"&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          French.Kiss Cherche une relation amoureuse.
                      &lt;/td&gt;
                      &lt;td&gt;
                      &lt;/td&gt;
                      &lt;td class="headline txtBlue size15" style="width:90px"&gt;
                          Education
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
                          Diplôme universitaire/Licence
                      &lt;/td&gt;
                  &lt;/tr&gt;
  
                  &lt;tr&gt;
                      &lt;td class="headline txtBlue size15"&gt;
                          Personnalité
                      &lt;/td&gt;
                      &lt;td style="width:10px"&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td class="txtGrey size15"&gt;
  
                      &lt;/td&gt;   &lt;td&gt;
                      &lt;/td&gt;
                  &lt;td&gt;
                              &lt;span class="headline txtBlue size15"&gt;Profession &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size15"&gt;
                                  Visioconférence&lt;/span&gt;
                          &lt;/td&gt;
                  &lt;/tr&gt;
  
              &lt;/table&gt; 
  </code></pre>
  
  <p>print tableUserDetailsList = [u'About', u'Fume occasionnellement with Silhouette mince', u'City', u'Paris Ile-de-France', u'Details', u'26 year old Un homme, 185cm, Sans religion', u'Ethnic
  ity', u'Caucasienne Balance with Ch\xe2tains', u'Intent', u'French.Kiss Cherche
  une relation amoureuse.', u'Education', u'Dipl\xf4me universitaire/Licence', u'P
  ersonnalit\xe9']</p>
  
  <p><strong>* SECOND TABLE *</strong></p>
  
  <p>print tableUserDetails.content = none</p>
  
  <p>print tableUserDetails = </p>
  
  <pre><code> &lt;table width="85%" class="secondpart"&gt;
                      &lt;tr height="25px"&gt;
                          &lt;td width="200px"&gt;
                              &lt;span class="headline txtBlue size14"&gt;I am Seeking a&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td width="300px"&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Une femme&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td width="25px"&gt;
                          &lt;/td&gt;
                          &lt;td width="200px"&gt;
                              &lt;span class="headline txtBlue size14"&gt;For&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td width="200px"&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Sorties&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;&lt;a href='needs_test.aspx'&gt;Needs Test&lt;/a&gt;&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;&lt;a href='needs_test.aspx'&gt;
  
  
                                  &lt;a href="needs_view.aspx?id=38028200"&gt;View
                                      his
                                      relationship needs&lt;/a&gt;&lt;/a&gt;&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;&lt;a href='poftest.aspx'&gt;Chemistry&lt;/a&gt;&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;&lt;a href='poftest.aspx'&gt;
  
                                  &lt;a href="personality.aspx?id=26&amp;user_id=41724176" rel="nofollow"&gt;View
                                      his
                                      chemistry results&lt;/a&gt;&lt;/a&gt;&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Do you drink?&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Occasionnellement&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Do you want children?&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Non divulgué&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Marital Status&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Célibataire&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Do you do drugs?&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Non&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Pets &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Aucun&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Eye Color&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Bruns&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Do you have a car? &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  N/A&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="headline txtBlue size14"&gt;Do you have children?&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Non&lt;/span&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr height="25px"&gt;
                          &lt;td&gt;
                           &lt;span class="headline txtBlue size14"&gt;Longest Relationship&lt;/span&gt;
                          &lt;/td&gt;
  
                          &lt;td&gt;
                              &lt;span class="txtGrey size14"&gt;
                                  Plus de 2 ans&lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
  
                          &lt;/td&gt;
                          &lt;td&gt;
  
                          &lt;/td&gt;
                      &lt;/tr&gt;
  
                  &lt;/table&gt; 
  </code></pre>
  
  <p>print tableUserDetailsList = []</p>