Thread View: es.comp.os.linux.programacion
1 messages
1 total messages
Started by Benjamín Albiñana Pérez
Sat, 14 Apr 2012 18:51
html entities y unicode con python
Author: Benjamín Albiñana Pérez
Date: Sat, 14 Apr 2012 18:51
Date: Sat, 14 Apr 2012 18:51
32 lines
2329 bytes
2329 bytes
A ver si consigo explicarme: Primer intento: >>> fromm BeautifulSoup import BeautifulSoup as BS >>> html_data = """ >>> ... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >>> "http://www.w3.org/TR/html4/loose.dtd"> >>> ... <html lang="es"> >>> ... <head> >>> ... <meta http-equiv="Content-Type" content="text/html; >>> charset=iso-8859-1"> >>> ... </head> >>> ... <body> >>> ... Corrección de errores a la Resolución >>> ... </body> >>> ... </html> >>> ... """ >>> soup = BS(html_data, convertEntities=BS.HTML_ENTITIES) >>> print soup.body.text Corrección de errores a la Resolución Segundo intento: >>> import HTMLParser >>> s = "Corrección de errores a la Resolución" >>> parser = HTMLParser.HTMLParser() >>> parser.unescape(s) >>> u'Correcci\xf3n de errores a la Resoluci\xf3n' Y aquí ya no sé como seguir, porque lo que yo quiero es "Correción de errores a la Resolución" ¿Alguna idea?
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads