ho il seguente testo:Il modo migliore per 'ripulire' testo HTML
"It's the show your only friend and pastor have been talking about!
<i>Wonder Showzen</i> is a hilarious glimpse into the black
heart of childhood innocence! Get ready as the complete first season of MTV2's<i> Wonder Showzen</i> tackles valuable life lessons like birth,
nature, diversity, and history – all inside the prison of
your mind! Where else can you..."
Quello che voglio fare con questo è rimuovere i tag HTML e codificare in unicode. Attualmente sto facendo:
def remove_tags(text):
return TAG_RE.sub('', text)
Quale solo strisce il tag. Come dovrei codificare correttamente quanto sopra per l'archiviazione del database?
Controlla questo argomento http://stackoverflow.com/questions/23380171/using-beautifulsoup-extract-text-without-tags –
Puoi spiegare, quando dici di codificarlo in Unicode, cosa ti aspetti come output? –
A proposito, quello che stai facendo con la tua espressione regolare è sbagliato. Non farlo. L'HTML non può essere analizzato usando regexp in modo che tutti i tentativi di farlo siano destinati a fallire. Usa invece un parser HTML, ecco a cosa servono. – spectras