I'm searching in a HTML document using XPath from lxml in python. How can I get the path to a certain element? Here's the example from ruby nokogiri:
page.xpath('//text()').each do |textnode|
path = textnode.path
puts path
end
print for example '/html/body/div/div[1]/div[1]/p/text()[1]' and this is the string I want to get in python.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…