views:

36

answers:

2

I want to add to my site ability to use some html-tags in text editor. So when user posts some text I need clean up this text - remove html-tags which are not allowed and leave allowed tags.

For example, on StackOverflow: http://meta.stackoverflow.com/questions/1777/what-html-tags-are-allowed

So I need some parser which has list of allowed tags and removes all other tags from given text.

I cannot find any solutions for Python. Is there some classes or libraries with such functionality? Or I have to write it from scratch using RegEx/substring()?

A: 

Python HTML sanitizer / scrubber / filter

Sanitising user input using Python

(old StackOverflow questions)

Fabian
A: 

Try using the Beautiful Soup module.

Zonda333