0

How use css selector find the last element in same elements each line on python? I'm using package pyquery.

I has tried tr td:nth-child(2) .score.fill:last-child, tr td:nth-child(2) .score.fill:nth-last-child(1). all failed.

<table>
    <tbody>
        <tr>
            <td>Vote A</td>
            <td>
                <span class="score fill">1</span>
                <span class="score">2</span>
                <span class="score">3</span>
                <span class="score">4</span>
                <span class="score">5</span>
            </td>
        </tr>
        <tr>
            <td>Vote B</td>
            <td>
                <span class="score fill">1</span>
                <span class="score fill">2</span>
                <span class="score fill">3</span>
                <span class="score fill">4</span>
                <span class="score fill">5</span>
            </td>
        </tr>
        <tr>
            <td>Vote C</td>
            <td>
                <span class="score fill">1</span>
                <span class="score fill">2</span>
                <span class="score fill">3</span>
                <span class="score">4</span>
                <span class="score">5</span>
            </td>
        </tr>
    </tbody>
</table>

I want get result like this:

<span class="score fill">1</span>
<span class="score fill">5</span>
<span class="score fill">3</span>
zzzz zzzz
  • 307
  • 2
  • 13

1 Answers1

0

this won't work, because of .score.fill:last-child this selector means element with classes score and fill AND also last child.

You can select this with only CSS, you have to located this by JS and for examle add one more class for them.

This is feature which will be in new css :nth selectors here is link

Here is something can help