I am pulling text out from an html tag attribute using lxml and xpath via tag.attrib['title']. I get:
Málaga Airport
where in the browser with the same url I am seeing:
Málaga Airport
How do I convert the former to the later?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It seems that the lxml html parser assumes a ‘latin1’ encoding for byte strings.
So unless the input is encoded as ‘latin1’ (or ‘ascii’), the encoding needs to be specified explicitly. In this case, it looks like it should be ‘utf-8’: