Last active
May 25, 2017 05:50
-
-
Save gshmu/da271d0c38416f366cd29725c29ea0fc to your computer and use it in GitHub Desktop.
python: bs4 html.parser self-close tag error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
html_str = "<html><body><p>tag-error<img src='a'><img src='b'><img src='c'></p></body></html>" | |
print(BeautifulSoup(html_str, 'html.parser').prettify()) | |
__out__ = """ | |
<html> | |
<body> | |
<p> | |
tag-error | |
<img src="a"> | |
<img src="b"> | |
<img src="c"/> | |
</img> | |
</img> | |
</p> | |
</body> | |
</html> | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
expect to happen:
<img src='a' /><img src='b' /><img src='c' />
actually:
<img src="a"><img src="b"><img src="c"/></img></img>