on master help sign in
Merge pull request #801 from dalf/extract_text

[fix] extract_text: use html.tostring instead html_to_text.

commit525e5d275c195d26cb9302ceb03f46ffffa6e730 authorAdam Tauber <asciimoo@gmail.com> dateMon 2 Jan 2017, 12:36 (10 years ago) parent3d8c9ba90e1db3
1 file changed+3−1
searx/engines/xpath.py+3−1
searx/engines/xpath.py+3−1
@@ -42,7 +42,9 @@ def extract_text(xpath_results):
4242 return ''.join(xpath_results)
4343 else:
4444 # it's a element
45− return html_to_text(xpath_results.text_content()).strip()
45+ text = html.tostring(xpath_results, encoding='unicode', method='text', with_tail=False)
46+ text = text.strip().replace('\n', ' ')
47+ return ' '.join(text.split())
4648
4749
4850def extract_url(xpath_results, search_url):