use fragment_fromstring instead of document_fromstring
This commit is contained in:
parent
7577b319ce
commit
8bda86c17d
1 changed files with 2 additions and 5 deletions
|
@ -398,8 +398,5 @@ def sanitize_fragment(html):
|
||||||
if not html:
|
if not html:
|
||||||
return u''
|
return u''
|
||||||
import lxml.html
|
import lxml.html
|
||||||
body = lxml.html.document_fromstring(html).find('body')
|
html = lxml.html.fragment_fromstring(html, create_parent=False)
|
||||||
html = lxml.html.tostring(body, encoding='utf-8')[6:-7].decode('utf-8')
|
return lxml.html.tostring(html, encoding='utf-8').decode('utf-8')
|
||||||
if html.startswith('<p>') and html.endswith('</p>'):
|
|
||||||
html = html[3:-4]
|
|
||||||
return html
|
|
||||||
|
|
Loading…
Reference in a new issue