Python/BeautifulSoup - how to remove all tags from an element?

后端 未结 7 1515
执念已碎
执念已碎 2020-11-28 06:01

How can I simply strip all tags from an element I find in BeautifulSoup?

相关标签:
7条回答
  • 2020-11-28 06:48

    Code to simply get the contents as text instead of html:

    'html_text' parameter is the string which you will pass in this function to get the text

    from bs4 import BeautifulSoup
    
    soup = BeautifulSoup(html_text, 'lxml')
    text = soup.get_text()
    print(text)
    
    0 讨论(0)
提交回复
热议问题