Python's equivalent to PHP's strip_tags?

后端 未结 7 1339
情歌与酒
情歌与酒 2020-12-15 18:26

Python\'s equivalent to PHP\'s strip_tags?

http://php.net/manual/en/function.strip-tags.php

7条回答
  •  遥遥无期
    2020-12-15 19:09

    Using BeautifulSoup

    from BeautifulSoup import BeautifulSoup
    soup = BeautifulSoup(htmltext)
    ''.join([e for e in soup.recursiveChildGenerator() if isinstance(e,unicode)])
    

提交回复
热议问题