from BeautifulSoup import BeautifulSoup def _remove_attrs(soup): tag_list = soup.findAll(lambda tag: len(tag.attrs) > 0) for t in tag_list: for attr, val in t.attrs: del t[attr] return soup def example(): doc = 'test

junk

blah
' print 'Before:\n%s' % doc soup = BeautifulSoup(doc) clean_soup = _remove_attrs(soup) print 'After:\n%s' % clean_soup