>>> from bs4 import BeautifulSoup as bs
>>> html = """<html>
<head><title>Test</title></head>
<body>
<p><b>para1</b><\p>
<p><b>para2</b><\p>
</body>
</html>"""
>>>
>>> soup = bs(html)
>>> html == str(soup)
False
>>> print html
<html>
<head><title>Test</title></head>
<body>
<p><b>para1</b><\p>
<p><b>para2</b><\p>
</body>
</html>
>>> print soup
<html>
<head><title>Test</title></head>
<body>
<p><b>para1</b><\p>
<p><b>para2</b><\p>
</p></p></body>
</html>
ご覧のとおり、html
とstr(soup)
.. の間には違いがあります。
< became <
> became >
なぜこうなった??