def generate_payloads(self, html_code, parent=None):
    e = []
    o = []
    l = []
    for (index, line) in enumerate(html_code.splitlines(), 1):
        o.append(line)
        l.append('<!-- {0} -->{1}'.format(index, line))
    tree = etree.HTML(decode_html('\n'.join(l))).getroottree()
    self.study(tree, entries=e, lines=l, parent=parent)
    self.settings = {'key': [], 'value': [], 'html': '', 'extra': {}, 'warning': [], 'error': []}
    for elem in e:
        if (elem['type'] == 'attrval'):
            found_node = etree.HTML(l[(int(elem['lineno']) - 1)]).xpath("//*[@*[re:test(., '{0}', 'i')]]".format(elem['identifier']), namespaces={'re': 'http://exslt.org/regular-expressions'})
            if (len(found_node) == 1):
                self.generateHandler(tree_node=tree, o=o, elem=elem)
        elif (elem['type'] == 'attrname'):
            found_node = etree.HTML(l[(int(elem['lineno']) - 1)]).xpath("//*[@*[re:test(name(.), '{0}', 'i')]]".format(elem['identifier']), namespaces={'re': 'http://exslt.org/regular-expressions'})
            if (len(found_node) == 1):
                self.generateHandler(tree_node=tree, o=o, elem=elem)
        elif (elem['type'] == 'tag'):
            found_node = etree.HTML(l[(int(elem['lineno']) - 1)]).xpath("//*[re:test(local-name(), '{0}', 'i')]".format(elem['identifier']), namespaces={'re': 'http://exslt.org/regular-expressions'})
            if (len(found_node) == 1):
                self.generateHandler(tree_node=tree, o=o, elem=elem)
        elif (elem['type'] == 'text'):
            found_node = etree.HTML(l[(int(elem['lineno']) - 1)]).xpath('//*[text()]')
            if (len(found_node) == 1):
                self.generateHandler(tree_node=tree, o=o, elem=elem)
        elif (elem['type'] == 'comment'):
            try:
                found_node = etree.HTML(l[(int(elem['lineno']) - 1)]).xpath('//*[comment()]')
            except:
                found_node = etree.HTML('{0}{1}{2}'.format('<div>', l[(int(elem['lineno']) - 1)], '</div>')).xpath("//comment()[re:test(., '{0}', 'i')]".format(elem['identifier']), namespaces={'re': 'http://exslt.org/regular-expressions'})
            if (len(found_node) == 1):
                self.generateHandler(tree_node=tree, o=o, elem=elem)
    self.settings['html'] = '\n'.join(o)
    if (not self.settings['warning']):
        self.settings.pop('warning', None)
    if (not self.settings['error']):
        self.settings.pop('error', None)
    return self.settings
def generate_payloads(self, html_code, parent=None):
    e = []
    o = []
    l = []
    for (index, line) in enumerate(html_code.splitlines(), 1):
        o.append(line)
        l.append('<!-- {0} -->{1}'.format(index, line))
    tree = etree.HTML(decode_html('\n'.join(l))).getroottree()
    self.study(tree, entries=e, lines=l, parent=parent)
    self.settings = {'key': [], 'value': [], 'html': , 'extra': {}, 'warning': [], 'error': []}
    for elem in e:
        if (elem['type'] == 'attrval'):
            found_node = etree.HTML(l[(int(elem['lineno']) - 1)]).xpath("//*[@*[re:test(., '{0}', 'i')]]".format(elem['identifier']), namespaces={'re': 'http://exslt.org/regular-expressions'})
            if (len(found_node) == 1):
                self.generateHandler(tree_node=tree, o=o, elem=elem)
        elif (elem['type'] == 'attrname'):
            found_node = etree.HTML(l[(int(elem['lineno']) - 1)]).xpath("//*[@*[re:test(name(.), '{0}', 'i')]]".format(elem['identifier']), namespaces={'re': 'http://exslt.org/regular-expressions'})
            if (len(found_node) == 1):
                self.generateHandler(tree_node=tree, o=o, elem=elem)
        elif (elem['type'] == 'tag'):
            found_node = etree.HTML(l[(int(elem['lineno']) - 1)]).xpath("//*[re:test(local-name(), '{0}', 'i')]".format(elem['identifier']), namespaces={'re': 'http://exslt.org/regular-expressions'})
            if (len(found_node) == 1):
                self.generateHandler(tree_node=tree, o=o, elem=elem)
        elif (elem['type'] == 'text'):
            found_node = etree.HTML(l[(int(elem['lineno']) - 1)]).xpath('//*[text()]')
            if (len(found_node) == 1):
                self.generateHandler(tree_node=tree, o=o, elem=elem)
        elif (elem['type'] == 'comment'):
            try:
                found_node = etree.HTML(l[(int(elem['lineno']) - 1)]).xpath('//*[comment()]')
            except:
                found_node = etree.HTML('{0}{1}{2}'.format('<div>', l[(int(elem['lineno']) - 1)], '</div>')).xpath("//comment()[re:test(., '{0}', 'i')]".format(elem['identifier']), namespaces={'re': 'http://exslt.org/regular-expressions'})
            if (len(found_node) == 1):
                self.generateHandler(tree_node=tree, o=o, elem=elem)
    self.settings['html'] = '\n'.join(o)
    if (not self.settings['warning']):
        self.settings.pop('warning', None)
    if (not self.settings['error']):
        self.settings.pop('error', None)
    return self.settings