html - CSS Selector only selects the first row -
i parsing html page , have long css selector (i can't figure out shorter one, because page stupid). should select tr in table, selects 2nd row... missing?
the selector:
body > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(8) > td:nth-child(1) > table:nth-child(4) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) tr:not(:first-child)
the page has multiple tables inside each other, first 90% not matter, after selecting table want work with, follow "[space]tr:not(...)
", should select descending rows, shouldn't it?
example html page (cannot link it, need login access it): http://pastebin.com/gprxtvzz
after selector selects table want (in selector ...> tbody:nth-child(1) tr:not(:first-child)
), age looks this:
<tbody> <tr valign="bottom"> <td class="blackmedium" width="80"><b>part number</b></td> <td class="blackmedium" width="100"><b>manufacturer</b></td> <td class="blackmedium" width="40"><b>abbr.</b></td> <td class="blackmedium" width="50"><b>wix part number</b></td> <td class="blackmedium" width="50"><b>lead time</b></td> </tr> <tr> <td class="blackmedium" width="80">a0002701098</td> <td class="blackmedium" width="100">mercedes-benz</td> <td class="blackmedium" width="40">mbz</td> <td class="blackmedium" width="50"> <a href="http://www.wixindustrialfilters.com/cross.aspx?part=w03at780" target="_blank">w03at780</a> </td> <td class="blackmedium" width="50"> stock </td> </tr> <tr bgcolor="#e0e0e0"> <td class="blackmedium" width="80">a0002701598 discontinued</td> <td class="blackmedium" width="100">mercedes-benz</td> <td class="blackmedium" width="40">mbz</td> <td class="blackmedium" width="50"> <a href="javascript:var w=window.open('partdetail.asp?part=58892','partdetail','left=200,top=200,width=530,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes');w.focus();">58892</a> </td> <td class="blackmedium" width="50"> </td> </tr> <tr> <td class="blackmedium" width="80">a0002772395</td> <td class="blackmedium" width="100">mercedes-benz</td> <td class="blackmedium" width="40">mbz</td> <td class="blackmedium" width="50"> <a href="javascript:var w=window.open('partdetail.asp?part=51249','partdetail','left=200,top=200,width=530,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes');w.focus();">51249</a> </td> <td class="blackmedium" width="50"> </td> </tr> <tr bgcolor="#e0e0e0"> <td class="blackmedium" width="80">a0002772895</td> <td class="blackmedium" width="100">mercedes-benz</td> <td class="blackmedium" width="40">mbz</td> <td class="blackmedium" width="50"> <a href="javascript:var w=window.open('partdetail.asp?part=57701','partdetail','left=200,top=200,width=530,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes');w.focus();">57701</a> </td> <td class="blackmedium" width="50"> </td> </tr> </tbody>
body > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(8) > td:nth-child(1) > table:nth-child(4) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) tr:not(:first-child)
not answering question, in case markup not parsing-friendly , need find nested in terrible markup table
element, prefer find presence of specific header in it. in case, may locate table having part number
header. example xpath:
//table[tr[1]/td/b = "part number"]
then, on table can use "not first child" css selector:
tr:not(:first-child)
or, may use adjacent selector (find tr
elements after tr
element, logically exclude first row):
tr + tr
hope simplify things.
Comments
Post a Comment