My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 79 attachment: example.py (395 bytes)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from html5lib import HTMLParser, treebuilders

html = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Pagetitle</title>
</head>
<body>
<div id="testid">test text</div>
</body>
</html>"""

doc = HTMLParser(tree = treebuilders.getTreeBuilder("dom")).parse(html)

assert doc.getElementById("testid") is not None
Powered by Google Project Hosting