PHP » PYTHON |
login |
register |
about
|
PYTHON strip_tags
is this article helpful?
|
Python replacement for PHP's strip_tags
[
edit
| history
]
Please refer to
http://zope.org/Members/chrisw/StripOGram/readme Strip-o-Gram HTML Conversion Library This is a library for converting HTML to Plain Text and stripping specified tags from HTML. from stripogram import html2text, html2safehtml mylumpofdodgyhtml # a lump of dodgy html ;-) # Only allow <b>, <a>, <i>, <br>, and <p> tags mylumpofcoolcleancollectedhtml = html2safehtml(mylumpofdodgyhtml,valid_tags=("b", "a", "i", "br", "p")) # Don't process <img> tags, just strip them out. Use an indent of 4 spaces # and a page that's 80 characters wide. mylumpoftext = html2text(mylumpofcoolcleancollectedhtml,ignore_tags=("img",),indent_width=4,page_width=80) If using Django you can use the built-in function strip_tags: from django.utils.html import strip_tags |
more
Recently updated
more
Most requested
more
Last requests
|