Python's equivalent to PHP's strip_tags?
http://php.net/manual/en/function.strip-tags.php
There is no such thing in the Python standard library. It's because Python is a general purpose language while PHP started as a Web oriented language.
Nevertheless, you have 3 solutions:
re.sub(r'<[^>]*?>', '', value)
can be a quick and dirty solution.Using BeautifulSoup
from BeautifulSoup import BeautifulSoup soup = BeautifulSoup(htmltext) ''.join([e for e in soup.recursiveChildGenerator() if isinstance(e,unicode)])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With