Тогда тебе нужна другая хорошая библиотека
У меня функция такая, но корявая конечно:
def Preprocessing (text):
text = str(text)
url_html = BeautifulSoup(text, 'html.parser')
body_texts_soup = url_html.find('body')
body_text = str(body_texts_soup)
body_text = body_text.replace("\r", ' ')
body_text = body_text.replace("\n", ' ')
link_and_anchor = re.compile(r'<a.*?/a>')
css = re.compile(r'<style.*?/style>')
body_text = body_text.replace('<script.*?</script>','')
css = re.compile(r'<style.*?/style>')
scripts = re.compile(r'<script.*?/script>')
noindex = re.compile(r'<!--noindex-->.*?<!--/noindex-->')
noscript = re.compile(r'<noscript.*?/noscript>')
body_text = link_and_anchor.sub(' ', body_text)
body_text = css.sub(' ', body_text)
body_text = scripts.sub(' ', body_text)
body_text = noindex.sub(' ', body_text)
body_text = noscript.sub(' ', body_text)
full_text = body_text.lower()
texts_soup = re.sub(r"\b[\w]{1,2}\b"," ",full_text)
texts_soup = re.sub(" +", " ", texts_soup)
del_text_tabs = re.sub(r'^\s+|\s+|\t+|\t|\!|\"|\©|\#|\$|\%|\&|\|\||\'|\(|\)|\*|\+|\,|\-|\.|\/|\:|\;|\<|\=|\>|\?|\@|\[|\|\\|\]|\^|\_|\`|\{|\||\}|\~', ' ', texts_soup)
del_tabs = re.sub(r'\s+', ' ', del_text_tabs)
return ( body_text )