Anpassungen des Codes an Django 1.11 mit Python 3
Grapelli wurde entfernt, das neue Django Admin ist hübsch genug.
This commit is contained in:
@@ -3,7 +3,8 @@ Created on 19.10.2011
|
||||
|
||||
@author: christian
|
||||
"""
|
||||
from BeautifulSoup import BeautifulSoup
|
||||
from bs4 import BeautifulSoup
|
||||
#TODO: Nach BeatutifulSoup 4 convertieren
|
||||
|
||||
|
||||
class HtmlCleaner(object):
|
||||
@@ -38,7 +39,7 @@ class HtmlCleaner(object):
|
||||
tag_removed = False
|
||||
|
||||
def clean_attributes(self, tag):
|
||||
for attr in tag._getAttrMap().keys():
|
||||
for attr in list(tag.attrs.keys()):
|
||||
if attr not in self.ACCEPTABELE_ATTRIBUTES:
|
||||
del tag[attr]
|
||||
elif tag[attr].count('script:'):
|
||||
@@ -57,14 +58,14 @@ class HtmlCleaner(object):
|
||||
@param fragment:
|
||||
"""
|
||||
while True:
|
||||
soup = BeautifulSoup(fragment)
|
||||
soup = BeautifulSoup(fragment, "html.parser")
|
||||
self.tag_removed = False
|
||||
self.counter += 1
|
||||
for tag in soup.findAll(True):
|
||||
for tag in soup.find_all(True):
|
||||
self.clean_tag(tag)
|
||||
fragment = unicode(soup)
|
||||
fragment = str(soup)
|
||||
if self.tag_removed:
|
||||
continue
|
||||
else:
|
||||
break
|
||||
return fragment
|
||||
return fragment.strip()
|
||||
|
||||
Reference in New Issue
Block a user