I have an html like this :
text = """<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
. remove me
</body>
</html>"""
What i want to do is to remove anything that is not inside a tag (. remove me) in this case
my code so far :
from bs4 import BeautifulSoup
text = """<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
. remove me
</body>
</html>"""
soup = BeautifulSoup(text,"html.parser")
print("".join(soup.strings))
But it doesn't remove it
Expected Output :
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>