网页防止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)

 

posted @ 2020-04-17 20:20  10132714  阅读(271)  评论(0)    收藏  举报