def take(self, *args):
"""
It returns the first object whose one of its
attributes matches (key0, value0), (key1, value1), ... .
Example:
data = '<a><b id="foo" size="1"></b></a>'
html = Html()
dom = html.feed(data)
print dom.take(('id', 'foo'))
print dom.take(('id', 'foo'), ('size', '2'))
"""
seq = self.match(*args)
try:
item = seq.next()
except StopIteration:
return None
else:
return item
评论列表
文章目录