@@ -3,13 +3,15 @@
33from collections.abc import Iterable
44from json import loads
55from urllib.parse import urlencode
6−from searx.utils import to_string
6+from searx.utils import to_string, html_to_text
77
88
99search_url = None
1010url_query = None
1111content_query = None
1212title_query = None
13+content_html_to_text = False
14+title_html_to_text = False
1315paging = False
1416suggestion_query = ''
1517results_query = ''
@@ -92,9 +94,17 @@ def request(query, params):
9294 return params
9395
9496
97+def identity(arg):
98+ return arg
99+
100+
95101def response(resp):
96102 results = []
97103 json = loads(resp.text)
104+
105+ title_filter = html_to_text if title_html_to_text else identity
106+ content_filter = html_to_text if content_html_to_text else identity
107+
98108 if results_query:
99109 rs = query(json, results_query)
100110 if not len(rs):
@@ -111,8 +121,8 @@ def response(resp):
111121 content = ""
112122 results.append({
113123 'url': to_string(url),
114− 'title': to_string(title),
115− 'content': to_string(content),
124+ 'title': title_filter(to_string(title)),
125+ 'content': content_filter(to_string(content)),
116126 })
117127 else:
118128 for url, title, content in zip(
@@ -122,8 +132,8 @@ def response(resp):
122132 ):
123133 results.append({
124134 'url': to_string(url),
125− 'title': to_string(title),
126− 'content': to_string(content),
135+ 'title': title_filter(to_string(title)),
136+ 'content': content_filter(to_string(content)),
127137 })
128138
129139 if not suggestion_query: