mirror of
https://github.com/status-im/status-app.git
synced 2026-08-31 00:51:10 +00:00
19 lines
456 B
Python
19 lines
456 B
Python
from bs4 import BeautifulSoup
|
|
|
|
|
|
def remove_tags(html):
|
|
# Handle None or empty input
|
|
if html is None:
|
|
return ''
|
|
if not isinstance(html, str):
|
|
return str(html) if html else ''
|
|
# parse html content
|
|
soup = BeautifulSoup(html, "html.parser")
|
|
|
|
for data in soup(['style', 'script']):
|
|
# Remove tags
|
|
data.decompose()
|
|
|
|
# return data by retrieving the tag content
|
|
return ' '.join(soup.stripped_strings)
|