Допустим, у нас есть html
файл, подобный этому:
test.html
<div>
<i>Some text here.</i>
Some text here also.<br>
2 + 4 = 6<br>
2 < 4 = True
</div>
Если я передам этот html
в BeautifulSoup
он выйдет из знака &
рядом с сущностью plus
, а вывод html
будет выглядеть примерно так:
<div>
<i>Some text here.</i>
Some text here also.<br>
2 &plus 4 = 6<br>
2 < 4 = True
</div>
Пример python3
код:
from bs4 import BeautifulSoup
with open('test.html', 'rb') as file:
soup = BeautifulSoup(file, 'html.parser')
print(soup)
Как я могу избежать этого поведения?