提问人:Shubham Gupta 提问时间:10/27/2021 最后编辑:Samsul IslamShubham Gupta 更新时间:10/27/2021 访问量:14
我正在使用 lxml.html 在 HTML 文件中添加新标签,然后对其进行操作,但它似乎不起作用
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
问:
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())
答: 暂无答案
评论