How do I make BeautifulSoup parse the contents of textarea tags as HTML?
- by brofield
Before 3.0.5, BeautifulSoup used to treat the contents of <textarea as HTML. It now treats it as text. The document I am parsing has HTML inside the textarea tags, and I am trying to process it.
I've tried:
for textarea in soup.findAll('textarea'):
contents = BeautifulSoup.BeautifulSoup(textarea.contents)
textarea.replaceWith(contents.html(text=True))
But I'm getting errors. I can't find this in the documentation, and the alternative parsers aren't helping. Anyone know how I can parse the textareas as HTML?