Converting html to text with Python

后端 未结 9 810
一生所求
一生所求 2020-12-12 17:49

I am trying to convert an html block to text using Python.

Input:

9条回答
  •  攒了一身酷
    2020-12-12 18:33

    The '\n' places a newline between the paragraphs.

    from bs4 import Beautifulsoup
    
    soup = Beautifulsoup(text)
    print(soup.get_text('\n'))
    

提交回复
热议问题