pyquery icon indicating copy to clipboard operation
pyquery copied to clipboard

has not support eq(index) string in filter selector?

Open jjwt opened this issue 9 years ago • 2 comments

it is found that .eq(index) selector works well as a outer selctor ,but not in filter string. Below is test function

def test_a():
    s = '''
    <html>
        <div id='ip_list'>
            <tr>
                <td>1</td>
                <td>2</td>
                <td>3</td>
                <td>4</td>
                <td>5</td>
                <td>6</td>
            </tr>
            <tr>
                <td>1</td>
                <td>2</td>
                <td>3</td>
                <td>4</td>
                <td>5</td>
                <td>6</td>
            </tr>
        </div>
    <html>
    '''
    from pyquery import PyQuery as pq
    print()
    print(pq(s)('#ip_list tr').eq(0))  # works fine
    print(pq(s)('#ip_list tr').filter(':eq(0)')) #does not work
    print(pq(s)('#ip_list tr').filter(':eq(0), :eq(1)')) #does not work either

jjwt avatar Jun 23 '16 08:06 jjwt

I love to use pyquery to do html work, I have the same question, and it's still not working now.

ayiis avatar Aug 23 '19 08:08 ayiis

Maybe the translation isn't correct https://github.com/gawel/pyquery/blob/master/pyquery/cssselectpatch.py#L367

gawel avatar Aug 23 '19 09:08 gawel