title: Find a List of Tags Based on Text Value of Children in Beautiful Soup
body: <p>I have a question about selecting a list of tags (or single tags) using a condition on one of the attributes of it's children. Specifically, given the HTML code:</p>
  
  <pre><code>&lt;tbody&gt;
  &lt;tr class="" data-row="0"&gt;
  &lt;tr class="" data-row="1"&gt;
  &lt;tr class="" data-row="2"&gt;
      &lt;td align="right" csk="13"&gt;13&lt;/td&gt;
      &lt;td align="left" csk="Jones,Andre"&gt;&lt;a href="/players/andre-jones-2.html"&gt;Andre Jones&lt;/a&gt;       
      &lt;/td&gt;
  &lt;tr class="" data-row="3"&gt;
      &lt;td align="right" csk="7"&gt;7&lt;/td&gt;
      &lt;td align="left" csk="Jones,DeAndre"&gt;&lt;a href="/players/deandre-jones-1.html"&gt;DeAndre Jones&lt;/a&gt;
      &lt;/td&gt;
   &lt;tr class="" data-row="4"&gt;
   &lt;tr class="" data-row="5"&gt;
  </code></pre>
  
  <p>I have a unicode variable coming from an external loop and I am trying to look through each row in the table to extract the <code>&lt;tr&gt;</code> tags with <code>Player==Table.tr.a.text</code> and to identify duplicate player names in <code>Table</code>. So, for instance, if there is more than one player with <code>Player=Andre Jones</code> the <code>MyRow</code> object returns all <code>&lt;tr&gt;</code> tags that contain that players name, while if there is only one row with <code>Player=Andre Jones</code>, then <code>MyRow</code> just contains the single element <code>&lt;tr&gt;</code> with anchor text attribute equal to <code>Andre Jones</code>. I've been trying things like</p>
  
  <pre><code>Table = soup.find('tbody')
  MyRow = Table.find_all(lambda X: X.name=='tr' and Player == X.text)
  </code></pre>
  
  <p>But this returns <code>[]</code> for <code>MyRow</code>. If I use</p>
  
  <pre><code>MyRow = Table.find_all(lambda X: X.name=='tr' and Player in X.text)
  </code></pre>
  
  <p>This will pick any <code>&lt;tr&gt;</code> that has <code>Player</code> as a substring of <code>X.text</code>. In the example code above, it extracts both <code>&lt;tr&gt;</code> tags withe <code>Table.tr.td.a.text=='Andre Jones'</code> and <code>Table.tr.td.a.text=='DeAndre Jones'</code>. Any help would be appreciated.</p>