lxml.etree, element.text doesn't return the entire text from an element

后端 未结 8 859
梦毁少年i
梦毁少年i 2021-02-07 10:39

I scrapped some html via xpath, that I then converted into an etree. Something similar to this:

 text1  link  text2 
<         


        
8条回答
  •  囚心锁ツ
    2021-02-07 11:06

    If the element is equal to . You can do the following.

    element.xpath('.//text()')
    

    It will give you a list of all text elements from self (the meaning of the dot). // means that it will take all elements and finally text() is the function to extract text.

提交回复
热议问题