Getting certain attribute value using XPath

后端 未结 1 1842
滥情空心
滥情空心 2021-02-08 11:58

From the following HTML snippet:





        
1条回答
  •  猫巷女王i
    2021-02-08 13:04

    Like this:

    data = """
    
    
    
    """
    
    from lxml import etree
    
    d = etree.HTML(data)
    
    d.xpath('//link[@rel="shortcut icon"]/@href')
    ['/img/all/favicon.ico']
    

    0 讨论(0)
提交回复
热议问题