【发布时间】:2015-12-13 14:13:39
【问题描述】:
我正在使用带有 lxml.html 库的 python 3.4。
我正在尝试从我使用 css 选择器定位的 html 元素中删除 border-bottom 内联样式。
这是一个显示示例 td 元素和我的选择器的代码片段:
html_snippet = lxml.html.fromstring("""<td valign="bottom" colspan="10" align="center" style="background-color:azure; border-bottom:1px solid #000000"><font style="font-family:Times New Roman" size="2">Estimated Future Payouts</font> \n <br/><font style="font-family:Times New Roman" size="2">Under Non-Equity Incentive</font> \n <br/><font style="font-family:Times New Roman" size="2">Plan Awards</font> \n </td>""")
selection = html_snippet.cssselect('td[style*="border-bottom"]')
selection.attrib['style']
>>>>'background-color: azure;border-bottom:1px solid #000000'
访问内联样式属性的正确方法是什么,以便我可以从我的选择器定位的任何元素中删除 border-bottom 属性?
【问题讨论】:
标签: python css html-parsing lxml lxml.html