How to select p tags without class attributes in Selectolax
21:59 06 Dec 2023

I am trying to select some p tags without class attributes using Selectolax without success. This is my code:

from selectolax.parser import HTMLParser

tree = HTMLParser(
    '''
    

123 My Rd. Suite 100 Anywhere , TX 12345

''' ) tree.css('p[class="card_street"] span:not([class]):nth-child(1)')

which gives:

[]

However, tree.css('p[class="card_street"] span:not([class])') is selecting the three span tags without a class attribute:

for node in tree.css('p[class="card_street"] > span:not([class])'):
    print(node.text())

gives:

 Anawhere
, TX
 12345

Can someone tell me the correct way to select the the 1st, 2nd, and 3rd span tags without class attributes?

python css-selectors html-parsing