From 050ab98058489ced22e1b44be83549a039f71939 Mon Sep 17 00:00:00 2001 From: Joseph Cheung Date: Thu, 2 Mar 2023 00:38:45 +0800 Subject: [PATCH] c --- searx/webapp.py | 10 ++++++++++ searx/webapp1.py | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/searx/webapp.py b/searx/webapp.py index bdb84fd09..025dc3e97 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -798,6 +798,16 @@ def search(): url_pair = [] url_proxy = {} prompt = "" + if request.environ['HTTP_CF_IPCOUNTRY'] == 'CN': + for res in results: + try: + if gfw.exists(res['title']): + results.remove(res) + # return index_error(output_format, gettext('No item found')), 500 + if gfw.exists(res['content']): + # return index_error(output_format, gettext('No item found')), 500 + results.remove(res) + except:pass for res in results: if 'url' not in res: continue if 'title' not in res: continue diff --git a/searx/webapp1.py b/searx/webapp1.py index 1f4690382..886885568 100644 --- a/searx/webapp1.py +++ b/searx/webapp1.py @@ -784,7 +784,7 @@ def search(): return index_error(output_format, e.message), 400 except Exception as e: # pylint: disable=broad-except logger.exception(e, exc_info=True) - return index_error(output_format, gettext('search error')), 500 + return index_error(output_format, gettext('No item found')), 500 # results results = result_container.get_ordered_results() @@ -798,14 +798,22 @@ def search(): url_pair = [] url_proxy = {} prompt = "" + if request.environ['HTTP_CF_IPCOUNTRY'] == 'CN': + for res in results: + try: + if gfw.exists(res['title']): + results.remove(res) + # return index_error(output_format, gettext('No item found')), 500 + if gfw.exists(res['content']): + # return index_error(output_format, gettext('No item found')), 500 + results.remove(res) + except:pass for res in results: if 'url' not in res: continue if 'title' not in res: continue - if request.environ['HTTP_CF_IPCOUNTRY'] == 'CN' and gfw.exists(res['title']): - return index_error(output_format, 'No query'), 400 + if 'content' not in res: continue - if request.environ['HTTP_CF_IPCOUNTRY'] == 'CN' and gfw.exists(res['content']): - return index_error(output_format, 'No query'), 400 + if res['content'] == '': continue new_url = 'https://url'+str(len(url_pair))