From 2ac3e5b20b50045574d55ff01cfa19f3ca9da8b9 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 11 Jun 2021 16:31:50 +0200 Subject: [PATCH] [fix] log messages from: google- images, news, scholar, videos - HTTP header Accept-Language --> lang_info['headers']['Accept-Language'] - remove obsolete query_url log messages which is already logged by httpx._client:HTTP request Signed-off-by: Markus Heiser --- searx/engines/google_images.py | 5 ++--- searx/engines/google_news.py | 5 ++--- searx/engines/google_scholar.py | 10 +++------- searx/engines/google_videos.py | 5 ++--- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py index 0f8f1c73e..e7382a6fe 100644 --- a/searx/engines/google_images.py +++ b/searx/engines/google_images.py @@ -103,6 +103,8 @@ def request(query, params): # pylint: disable=undefined-variable params, supported_languages, language_aliases, False ) + logger.debug( + "HTTP header Accept-Language --> %s", lang_info['headers']['Accept-Language']) query_url = 'https://' + lang_info['subdomain'] + '/search' + "?" + urlencode({ 'q': query, @@ -117,11 +119,8 @@ def request(query, params): query_url += '&' + urlencode({'tbs': 'qdr:' + time_range_dict[params['time_range']]}) if params['safesearch']: query_url += '&' + urlencode({'safe': filter_mapping[params['safesearch']]}) - - logger.debug("query_url --> %s", query_url) params['url'] = query_url - logger.debug("HTTP header Accept-Language --> %s", lang_info.get('Accept-Language')) params['headers'].update(lang_info['headers']) params['headers']['Accept'] = ( 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' diff --git a/searx/engines/google_news.py b/searx/engines/google_news.py index 71b6093d3..485d602bc 100644 --- a/searx/engines/google_news.py +++ b/searx/engines/google_news.py @@ -85,6 +85,8 @@ def request(query, params): # pylint: disable=undefined-variable params, supported_languages, language_aliases, False ) + logger.debug( + "HTTP header Accept-Language --> %s", lang_info['headers']['Accept-Language']) # google news has only one domain lang_info['subdomain'] = 'news.google.com' @@ -107,11 +109,8 @@ def request(query, params): 'oe': "utf8", 'gl': lang_info['country'], }) + ('&ceid=%s' % ceid) # ceid includes a ':' character which must not be urlencoded - - logger.debug("query_url --> %s", query_url) params['url'] = query_url - logger.debug("HTTP header Accept-Language --> %s", lang_info.get('Accept-Language')) params['headers'].update(lang_info['headers']) params['headers']['Accept'] = ( 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' diff --git a/searx/engines/google_scholar.py b/searx/engines/google_scholar.py index fbf443e2e..8442a7bfa 100644 --- a/searx/engines/google_scholar.py +++ b/searx/engines/google_scholar.py @@ -77,12 +77,11 @@ def request(query, params): offset = (params['pageno'] - 1) * 10 lang_info = get_lang_info( # pylint: disable=undefined-variable - - - # params, {}, language_aliases - params, supported_languages, language_aliases, False ) + logger.debug( + "HTTP header Accept-Language --> %s", lang_info['headers']['Accept-Language']) + # subdomain is: scholar.google.xy lang_info['subdomain'] = lang_info['subdomain'].replace("www.", "scholar.") @@ -95,11 +94,8 @@ def request(query, params): }) query_url += time_range_url(params) - - logger.debug("query_url --> %s", query_url) params['url'] = query_url - logger.debug("HTTP header Accept-Language --> %s", lang_info.get('Accept-Language')) params['headers'].update(lang_info['headers']) params['headers']['Accept'] = ( 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' diff --git a/searx/engines/google_videos.py b/searx/engines/google_videos.py index 81e0a8473..c57db4e63 100644 --- a/searx/engines/google_videos.py +++ b/searx/engines/google_videos.py @@ -121,6 +121,8 @@ def request(query, params): # pylint: disable=undefined-variable params, supported_languages, language_aliases, False ) + logger.debug( + "HTTP header Accept-Language --> %s", lang_info['headers']['Accept-Language']) query_url = 'https://' + lang_info['subdomain'] + '/search' + "?" + urlencode({ 'q': query, @@ -134,11 +136,8 @@ def request(query, params): query_url += '&' + urlencode({'tbs': 'qdr:' + time_range_dict[params['time_range']]}) if params['safesearch']: query_url += '&' + urlencode({'safe': filter_mapping[params['safesearch']]}) - - logger.debug("query_url --> %s", query_url) params['url'] = query_url - logger.debug("HTTP header Accept-Language --> %s", lang_info.get('Accept-Language')) params['headers'].update(lang_info['headers']) params['headers']['Accept'] = ( 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'