title: beautiful soup extracting parent/sibling tr table class
body: <p>I am trying to get to grips with bs4, however, I am having some trouble extracting some info from the following html:</p>
  
  <pre><code>&lt;table border="1" cellspacing="0" class="browser"&gt;
  &lt;thead&gt;..&lt;/thead&gt;
  &lt;tbody class="body"&gt;
  &lt;tr class="date"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  &lt;tr class="date"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>So, what I'd like to have is the content (<code>class</code>) between the two <code>date classes</code> like so:</p>
  
  <pre><code>&lt;tr class="date"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  </code></pre>
  
  <p>and,</p>
  
  <pre><code>&lt;tr class="date"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  &lt;tr class="right"&gt;..&lt;/tr&gt;
  </code></pre>
  
  <p>I have tried doing:</p>
  
  <pre><code>xx = soup.find_all('tbody',{'class':'body'})
  </code></pre>
  
  <p>and to get the corresponding <code>right classes</code> I do:</p>
  
  <pre><code>yy = []
  for i in xx:
      yy.append( i.find_all('tr',{'class':'right'}) )
  </code></pre>
  
  <p>...but this gives me all the <code>right classes</code>, but I would somehow like to establish what the parent <code>date</code> class for each of these elements in <code>yy</code> are. In a nutshell, I would want each of the <code>right classes</code> associated with its <code>parent date class</code></p>
  
  <p>Sorry in advance if the question seems confusing!</p>