1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-19 02:40:11 +01:00

Merge pull request #801 from dalf/extract_text

[fix] extract_text: use html.tostring instead html_to_text.
This commit is contained in:
Adam Tauber 2017-01-02 12:36:50 +01:00 committed by GitHub
commit 525e5d275c

View File

@ -42,7 +42,9 @@ def extract_text(xpath_results):
return ''.join(xpath_results) return ''.join(xpath_results)
else: else:
# it's a element # it's a element
return html_to_text(xpath_results.text_content()).strip() text = html.tostring(xpath_results, encoding='unicode', method='text', with_tail=False)
text = text.strip().replace('\n', ' ')
return ' '.join(text.split())
def extract_url(xpath_results, search_url): def extract_url(xpath_results, search_url):