Created
April 24, 2009 20:04
-
-
Save FND/101319 to your computer and use it in GitHub Desktop.
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
# -*- coding: UTF-8 -*- | |
""" | |
test case for the following error: | |
UnicodeEncodeError: | |
'ascii' codec can't encode character u'\xf6' in position 1: | |
ordinal not in range(128) | |
""" | |
import html5lib | |
document = u""" | |
<html> | |
<body> | |
<p>lörem ipsüm dÅlor sät æmet</p> | |
</body> | |
</html> | |
""" | |
tree = html5lib.treebuilders.getTreeBuilder("dom") | |
parser = html5lib.HTMLParser(tree=tree) | |
doc = parser.parse(document) | |
el = doc.getElementsByTagName("p")[0] | |
text = el.firstChild | |
print text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment