From the following HTML snippet:
Like this:
data = """ """ from lxml import etree d = etree.HTML(data) d.xpath('//link[@rel="shortcut icon"]/@href') ['/img/all/favicon.ico']