def find_existing_anchors(soup):
 existing_anchors = set()
 for tag in soup.find_all(True):
  for attr in [u'id', u'name']:
   if tag.has_attr(attr):
    existing_anchors.add(tag.get(attr))
 return existing_anchors

def find_existing_anchors ( soup ) : existing_anchors = set ( ) for tag in soup . find_all ( True ) : for attr in [ u'id' , u'name' ] : if tag . has_attr ( attr ) : existing_anchors . add ( tag . get ( attr ) ) return existing_anchors
return existing ids from a soup .