The first situation: there is a link in the tag
from lxml import etree
node = etree.fromstring('<a xml = 'www.www.com'><c>bum</c></a>')
print node.findtext('c',default = 'what happened?')
Second situation: The tag above the requested text has no content
from lxml import etree
node = etree.fromstring('<a><b><c>bum</c></b></a>')
print node.findtext('c', default = 'what happened?')
The results returned by the above two situations are ‘None’
Successful situation
from lxml import etree
node = etree.fromstring('<a><c>bum</c></a>')
print node.findtext('c')
I would like to ask how to solve these two problems?
I recommend pyquery to you, I personally think it is more useful