def walk(self):
"""
Like sail but carries name and attr.
Example:
html = Html()
data = '<body> <em> This is all the text.</em></body>'
dom = html.feed(data)
for ind, name, attr in dom.walk():
print 'TAG:', ind
print 'NAME:', name
print 'ATTR:', attr
It should print.
TAG:
NAME: 1
ATTR:
TAG: This is all the text.
NAME: 1
ATTR:
TAG: <em > This is all the text.</em>
NAME: em
ATTR:
TAG: <body > <em > This is all the text.</em></body>
NAME: body
ATTR:
"""
for ind in self.sail():
yield (ind, ind.name, ind.attr)
评论列表
文章目录