BeautifulSoup - combine consecutive tags

前端 未结 2 1573
孤独总比滥情好
孤独总比滥情好 2021-01-19 14:11

I have to work with the messiest HTML where individual words are split into separate tags, like in the following example:



        
2条回答
  •  有刺的猬
    2021-01-19 14:18

    Perhaps you could check if the b.previousSibling is a b tag, then append the inner text from the current node into that. After doing this - you should be able to remove the current node from the tree with b.decompose.

提交回复
热议问题