mirror of https://github.com/searxng/searxng.git
[fix] error when xpath_results in extraxt_text is _ElementUnicodeResult instead of _ElementStringResult
This commit is contained in:
parent
693415c787
commit
6f535b6fae
|
@ -1,7 +1,7 @@
|
||||||
from lxml import html
|
from lxml import html
|
||||||
from urllib import urlencode, unquote
|
from urllib import urlencode, unquote
|
||||||
from urlparse import urlparse, urljoin
|
from urlparse import urlparse, urljoin
|
||||||
from lxml.etree import _ElementStringResult
|
from lxml.etree import _ElementStringResult, _ElementUnicodeResult
|
||||||
from searx.utils import html_to_text
|
from searx.utils import html_to_text
|
||||||
|
|
||||||
search_url = None
|
search_url = None
|
||||||
|
@ -29,7 +29,7 @@ def extract_text(xpath_results):
|
||||||
for e in xpath_results:
|
for e in xpath_results:
|
||||||
result = result + extract_text(e)
|
result = result + extract_text(e)
|
||||||
return result
|
return result
|
||||||
elif type(xpath_results) == _ElementStringResult:
|
elif type(xpath_results) in [_ElementStringResult, _ElementUnicodeResult]:
|
||||||
# it's a string
|
# it's a string
|
||||||
return ''.join(xpath_results)
|
return ''.join(xpath_results)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue