网页防止xss攻击

from bs4 import BeautifulSoup

soup = BeautifulSoup(content, 'html.parser')  # content为获取的用户上传内容

tags = soup.find_all()

for tag in tags:

  if tag.name == 'script':

    tag.decompose()

content = str(soup)

原文地址:https://www.cnblogs.com/JackShi/p/12722237.html