Spaces:
Sleeping
Sleeping
File size: 851 Bytes
6d6e4bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# Import Module
from bs4 import BeautifulSoup
# HTML Document
HTML_DOC = """
<html>
<head>
<title> Geeksforgeeks </title>
<style>.call {background-color:black;} </style>
<script>getit</script>
</head>
<body>
is a
<div>Computer Science portal.</div>
</body>
</html>
"""
# Function to remove tags
def remove_tags(html):
# 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)
# Print the extracted data
print(remove_tags(HTML_DOC))
|