Skip to content Skip to sidebar Skip to footer

How To Render Contents Of A Tag In Unicode In Beautifulsoup?

This is a soup from a WordPress post detail page: content = soup.body.find('div', id=re.compile('post')) title = content.h2.extract() item['title'] = unicode(title.string) item['co

Solution 1:

Have you tried:

unicode(content)

It converts content's markup to a single Unicode string.

Edit: If you don't want the enclosing tag, try:

content.renderContents()

Post a Comment for "How To Render Contents Of A Tag In Unicode In Beautifulsoup?"