我正试着用一个特殊的
身份证件
使用美容品组。
from django import template
from bs4 import BeautifulSoup
register = template.Library()
@register.filter(name='reset_html_styles')
def reset_html_styles(value):
# value = '<div class="test"><div dir="ltr" id="divRplyFwdMsg"><p>Some paragraph</p></div></div>'
soup = BeautifulSoup(value, 'html5lib')
soup.find('div', id='divRplyFwdMsg').decompose()
return str(soup)
Error: 'NoneType' object has no attribute 'decompose'
我在用
python 3.6.5
,
django 2.0
和
beautifulsoup4 4.6.0