soup.select("table tr td:nth-of-type(1)") not return list

Bug #1490007 reported by tablecell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Beautiful Soup
New
Undecided
Unassigned

Bug Description

here is test code
-----------------------------------------------------------------------
from bs4 import BeautifulSoup
text='''

<html><head><style>
table tr td:nth-of-type(1){
background:red;
}
</style></head><body>
<div id="r_2368837" class="cell">
        <table cellpadding="0" cellspacing="0" border="0" width="100%">
            <tr>
                <td > php </td>
                <td > 100 </td>
                <td > first </td>
            </tr>
            <tr><td> total xxxx </td></tr>
  </table>
</div>
<div id="r_2368838" class="cell">
        <table cellpadding="0" cellspacing="0" border="0" width="100%">
            <tr>
                <td > python </td>
                <td > 200 </td>
                <td > second </td>
            </tr>
         <tr> <td> tatal aaaa </td></tr>
       </table>
</div>

</body></html>
'''

soup =BeautifulSoup(text,"html.parser",from_encoding='utf-8')
out=soup.select("table tr td:nth-of-type(1)")
for tr in out:
    print("\n-----------")
    print(tr)
------------------------------------------------------------------
expect list [ "<td > php </td>",
              " <td> total xxxx </td>",
              "<td > python </td>",
              " <td> tatal aaaa </td>"]

but return only first element " <td > php </td> "
save the text as test.html ,you can see the correct result

tablecell (tablecell)
description: updated
description: updated
tablecell (tablecell)
description: updated
description: updated
description: updated
Revision history for this message
Leonard Richardson (leonardr) wrote :

I'm pretty sure this is the same as bug #150760.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.