Python xpath使用

from lxmlimport etree

html= '''


        我左青龙,

            右白虎,            上朱雀,               

  • 下玄武。

                老牛在当中,

            龙头在胸口。

    '''

    selector= etree.HTML(html)

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

    print(content1)

    for xin content1:

        print(x)

  • 你可能感兴趣的:(Python xpath使用)