from bs4 import BeautifulSoup 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)