How to get path of an element in lxml?

后端 未结 4 1281
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 01:29

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.         


        
4条回答
  •  野性不改
    2020-11-30 01:46

    root = etree.parse(open('tmp.txt'))
    
    for e in root.iter():
        print root.getpath(e)
    

提交回复
热议问题