Remove empty classes from elements.
This commit is contained in:
parent
68a555cfd8
commit
3ad862a9d0
1 changed files with 5 additions and 0 deletions
|
@ -235,6 +235,11 @@ def remove_unwanted_classes_ids(soup):
|
||||||
else:
|
else:
|
||||||
tag['class'] = list(tag['class'])
|
tag['class'] = list(tag['class'])
|
||||||
|
|
||||||
|
try:
|
||||||
|
tag['class'].remove('')
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
# Intentional list() duplicate so we can remove from original.
|
# Intentional list() duplicate so we can remove from original.
|
||||||
for cls in list(tag['class']):
|
for cls in list(tag['class']):
|
||||||
if any(re.match(pattern, cls) for pattern in PATTERNS):
|
if any(re.match(pattern, cls) for pattern in PATTERNS):
|
||||||
|
|
Loading…
Reference in a new issue