data = """<link rel="index" href="/index.php" />
<link rel="contents" href="/getdata.php" />
<link rel="copyright" href="/blabla.php" />
<link rel="shortcut icon" href="/img/all/favicon.ico" />
"""
from lxml import etree
d = etree.HTML(data)
d.xpath('//link[@rel="shortcut icon"]/@href')
Getting certain attribute value using XPath