'Extract the unique set of HTML attributes used in the content'

@newrelic.agent.function_trace()
def html_attributes(self):

    try:
        attribs = []
        for token in parse(self.document.rendered_html).stream:
            if (token['type'] == 'StartTag'):
                for ((namespace, name), value) in token['data'].items():
                    attribs.append((name, value))
        return [('%s="%s"' % (k, v)) for (k, v) in attribs]
    except:
        return []
