0
私はBBC_news_home.htmlと呼ばれるファイルを持っています。すべてのマークアップタグを削除する必要があります。これまでのところ私が得た:Python - マークアップタグを削除し、ファイルからHTMLを読み込みますか?
def clean_html(html):
cleaned = ''
line = html
pattern = r'(<.*?>)'
result = re.findall(pattern, line, re.S)
if result:
f = codecs.open("BBC_news_home.html", 'r', 'utf-8')
print(f.read())
else:
print('Not cleaned.')
return cleaned
私はパターンが正しいイムだけでマークアップタグがなくなっているかどうかを確認するために出力を印刷する方法がわからないことをregex101.comでチェックしていますか?
[BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/)、具体的には[.get_text()](https://www.crummy。 com/software/BeautifulSoup/bs4/doc /#get-text)。 –