Python/BeautifulSoup - how to remove all tags from an element?
How can I simply strip all tags from an element I find in BeautifulSoup?
Solution 1:
With BeautifulStoneSoup
gone in bs4
, it's even simpler in Python3
from bs4 import BeautifulSoup
soup = BeautifulSoup(html)
text = soup.get_text()
print(text)
Solution 2:
why has no answer I've seen mentioned anything about the unwrap
method? Or, even easier, the get_text
method
http://www.crummy.com/software/BeautifulSoup/bs4/doc/#unwrap http://www.crummy.com/software/BeautifulSoup/bs4/doc/#get-text