', '">').replace('', '').rstrip("'")) y" /> ', '">').replace('', '').rstrip("'")) y" /> ', '">').replace('', '').rstrip("'")) y"/>

I'm working with lxml.html Adding new tags in the HTML file and then manipulating it but it doesn't seems to be working

16 Views Asked by At
for y in row_data:
    say = html.fromstring(
        str(html.tostring(y)).lstrip("b'").replace('">', '"><span>').replace('</td>', '</span></td>').rstrip("'"))
    y.addprevious(say)
    y.getparent().remove(y)


#[x.attrib['style'] for x in row_data if number.search(x.text_content()) and not date_pattern.search(x.text_content())]
for x in row_data:
    if number.search(x.text_content()) and not date_pattern.search(x.text_content()):
        x.attrib['style'] = x.attrib['style']+"color:orange;"
        #x.set('<span class="Numbers">', value=x.text_content())
        x.set('class="Numbers"', value=x.text_content())

    elif date_pattern.findall(x.text_content()):
        x.attrib['style'] = x.attrib['style']+"color:red;"
        x.set('class="Dates"', value=x.text_content())
0

There are 0 best solutions below