data = urllib.request.urlopen('https://en.wikipedia.org')
tree = etree.parse(data)
element = tree.xpath('//div[@id="p-logo"]/a')[0]
print(tree.getpath(element))
How to get an XPath from selenium webelement or from lxml?