Fixed and finished the search function
This commit is contained in:
@@ -4,15 +4,11 @@ from bs4 import BeautifulSoup
|
||||
|
||||
def strip_html_tags(html):
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
|
||||
# Remove script and style elements completely
|
||||
for tag in soup(["script", "style"]):
|
||||
tag.decompose()
|
||||
|
||||
# Extract plain text
|
||||
text = soup.get_text(separator="\n")
|
||||
|
||||
# Clean up whitespace
|
||||
lines = [line.strip() for line in text.splitlines() if line.strip()]
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user