readabilite: also use BS
parent
568e7d7dd2
commit
6cf32af6c0
|
@ -1,5 +1,6 @@
|
||||||
import lxml.etree
|
import lxml.etree
|
||||||
import lxml.html
|
import lxml.html
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +10,7 @@ def parse(data, encoding=None):
|
||||||
else:
|
else:
|
||||||
parser = lxml.html.HTMLParser(remove_blank_text=True, remove_comments=True)
|
parser = lxml.html.HTMLParser(remove_blank_text=True, remove_comments=True)
|
||||||
|
|
||||||
return lxml.html.fromstring(data, parser=parser)
|
return lxml.html.fromstring(BeautifulSoup(data, 'lxml').prettify('utf-8'), parser=parser)
|
||||||
|
|
||||||
|
|
||||||
def count_words(string):
|
def count_words(string):
|
||||||
|
|
Loading…
Reference in New Issue