I would like to retrieve the literal text from an xpath using lxml. Unfortunately, it converts entityrefs as shown below:
from lxml import etree
tree = etree.HTML('<html><body><div>&</div></body></html>')
text = tree.xpath('/html[1]/body[1]/div[1]')[0].text
print(text)
>>> &
Is there some way to prevent the conversion or am I stuck having to back-convert it?