from BeautifulSoup import BeautifulSoup
page = BeautifulSoup('<foo bar="asdf" blah="123">xyz</foo>')
for attr, value in page.find('foo').attrs:
    pass
Как перебирать HTML-атрибуты элемента Beautiful Soup?