2024-09-30 10:33:28 发布
网友
我有一个html表格。 在那张桌子上
<td>abc</td><a>www.abc.com</a>
如何使用匹配td的值来获得链接值?在
例如:如何获得www.abc.com网站用lxml搜索tect-abc?在
a/text()获取文本
a/text()
a/@href获取attr(在本例中是href)
a/@href
href
升级版
>>> from lxml import etree >>> etree.fromstring('<html><td>abc</td><a>www.abc.com</a></html>').xpath("//td/following-sibling::a/text()") ['www.abc.com']
XPath 1.0
a/text()
获取文本a/@href
获取attr(在本例中是href
)升级版
XPath 1.0
相关问题 更多 >
编程相关推荐