To get the correct content I desire within many, many pages - I have come up with a rule that works 99% of the time:
//a[@class='popular class' and not (contains(text(),'text1')) and not (contains(text(),'text2'))]
The other 1% results in finding more than 1 matching node, and requires more special treatment of "not (contains(text(), 'specialtext'))
What I figured out, is that the value I desire has only 1 character and up to a maximum of 4, while the special treatment cases will always exceed 4 digits.
What I'm trying to do is to add another condition in my xpath that would look like this:
//a[@class='popular class' and not (contains(text(),'text1')) and not (contains(text(),'text2')) and (text_length() < 5)]
This should work as a 100% rule that will always get me the specific node I need. I have seen something equivalent in Java:
System.out.println("Select elements which
have string length less than 4");
expr = xpath.compile(".//*[string-length(name()) < '4']")
But couldn't find a matching function with Python.
Is there any?