title: How to find tags with only certain attributes - BeautifulSoup
body: <p>How would I, using BeautifulSoup, search for tags containing ONLY the attributes I search for? </p>
  
  <p>For example, I want to find all <code>&lt;td valign="top"&gt;</code> tags. </p>
  
  <p>The following code:
  <code>raw_card_data = soup.fetch('td', {'valign':re.compile('top')})</code></p>
  
  <p>gets all of the data I want, but also grabs any <code>&lt;td&gt;</code> tag that has the attribute <code>valign:top</code> </p>
  
  <p>I also tried:
  <code>raw_card_data = soup.findAll(re.compile('&lt;td valign="top"&gt;'))</code>
  and this returns nothing (probably because of bad regex)</p>
  
  <p>I was wondering if there was a way in BeautifulSoup to say "Find <code>&lt;td&gt;</code> tags whose only attribute is <code>valign:top</code>"</p>
  
  <p><strong>UPDATE</strong>
  FOr example, if an HTML document contained the following <code>&lt;td&gt;</code> tags:</p>
  
  <pre><code>&lt;td valign="top"&gt;.....&lt;/td&gt;&lt;br /&gt;
  &lt;td width="580" valign="top"&gt;.......&lt;/td&gt;&lt;br /&gt;
  &lt;td&gt;.....&lt;/td&gt;&lt;br /&gt;
  </code></pre>
  
  <p>I would want only the first <code>&lt;td&gt;</code> tag (<code>&lt;td width="580" valign="top"&gt;</code>) to return</p>