🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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
#193
Author: Benjamín Albiñana Pérez
Date: Sat, 14 Apr 2012 18:51
32 lines
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&#xF3;n de errores a la Resoluci&#xF3;n
>>> ... </body>
>>> ... </html>
>>> ... """
>>> soup = BS(html_data, convertEntities=BS.HTML_ENTITIES)
>>> print soup.body.text
Correcci&#xF3;n de errores a la Resoluci&#xF3;n

Segundo intento:
>>> import HTMLParser
>>> s = "Correcci&#xF3;n de errores a la Resoluci&#xF3;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