美文网首页
Python xpath使用

Python xpath使用

作者: 郭青茄 | 来源:发表于2020-05-04 17:40 被阅读0次

from lxmlimport etree

html= '''

        我左青龙,

            右白虎,            <u1>上朱雀,                <li>下玄武。

            老牛在当中,

        龙头在胸口。

'''

selector= etree.HTML(html)

content1= selector.xpath('//div[@id="test3"]/span/text()')

print(content1)

for xin content1:

    print(x)

相关文章

网友评论

      本文标题:Python xpath使用

      本文链接:https://www.haomeiwen.com/subject/kwjyghtx.html