on master help sign in
update comment
commite39d9fe5423a0fceed1d15dc63c1f8aa30d72e44 authorDalf <alex@al-f.net> dateMon 22 Sep 2014, 23:39 (12 years ago) parent6b05896
1 file changed+6−5
searx/search.py+6−5
searx/search.py+6−5
@@ -106,8 +106,13 @@ def score_results(results):
106106 res['host'] = res['host'].replace('www.', '', 1)
107107
108108 res['engines'] = [res['engine']]
109+
109110 weight = 1.0
110111
112+ # strip multiple spaces and cariage returns from content
113+ if 'content' in res:
114+ res['content'] = re.sub(' +', ' ', res['content'].strip().replace('\n', ''))
115+
111116 # get weight of this engine if possible
112117 if hasattr(engines[res['engine']], 'weight'):
113118 weight = float(engines[res['engine']].weight)
@@ -115,12 +120,8 @@ def score_results(results):
115120 # calculate score for that engine
116121 score = int((flat_len - i) / engines_len) * weight + 1
117122
118− duplicated = False
119−
120123 # check for duplicates
121− if 'content' in res:
122− res['content'] = re.sub(' +', ' ', res['content'].strip().replace('\n', ''))
123−
124+ duplicated = False
124125 for new_res in results:
125126 # remove / from the end of the url if required
126127 p1 = res['parsed_url'].path[:-1] if res['parsed_url'].path.endswith('/') else res['parsed_url'].path # noqa