I have the next expression:
population = tree.xpath('(//tr/td/b/a[contains(text(), "Population")]/../../following-sibling::td/span/following-sibling::text())[1] or'
'//tr/td/b/a[contains(text(), "Population")]/../../following-sibling::td/span/text())
which returns 'True'.
If I use "|" instead of 'or', it combines values of the 1st and 2nd paths, like this ['11 061 886', '▼'].
How to make the logic like:
If the 1st path exists:
get the 1st value
elif the 2nd path exists:
get the 2nd value
else:
pass
?
I understand that this is simple, but can't find the answer.