parsers.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:de-visualization-wizard 作者: deleidos 项目源码 文件源码
def childNodesWithText(self, node):
        root = node
        # create the first text node
        # if we have some text in the node
        if root.text:
            t = lxml.html.HtmlElement()
            t.text = root.text
            t.tag = 'text'
            root.text = None
            root.insert(0, t)
        # loop childs
        for c, n in enumerate(list(root)):
            idx = root.index(n)
            # don't process texts nodes
            if n.tag == 'text':
                continue
            # create a text node for tail
            if n.tail:
                t = self.createElement(tag='text', text=n.tail, tail=None)
                root.insert(idx + 1, t)
        return list(root)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号