def prune_useless_elements(path_root):
to_remove = []
for c in path_root.children:
for useless in USELESS_KEYWORDS:
if c.id and (distance(c.id, useless) <= MAX_DISTANCE or useless in c.id):
#print('Removing {0} because of id {1}'.format(c, useless))
to_remove.append(c)
if c.cls:
for cl in c.cls:
if distance(cl, useless) <= MAX_DISTANCE or useless in cl:
#print('Removing {0} because of class name {1}'.format(c, cl))
to_remove.append(c)
path_root.children = [c for c in path_root.children if c not in to_remove]
for c in path_root.children:
prune_useless_elements(c)
评论列表
文章目录