logo

searx

Unnamed repository; edit this file 'description' to name the repository.
commit: 6d55642ab4bb82fe4274acba74464fefefb9f1a2
parent: ba16f213b02aaf081ce0a59f86d95196039eb884
Author: Adam Tauber <asciimoo@gmail.com>
Date:   Fri, 25 Mar 2016 18:38:02 +0100

[fix] no more redirect ++ explicitly specify search language to avoid googles ip based heuristics

Diffstat:

searx/engines/google.py | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/searx/engines/google.py b/searx/engines/google.py @@ -90,7 +90,7 @@ url_map = 'https://www.openstreetmap.org/'\ search_path = '/search' search_url = ('https://{hostname}' + search_path + - '?{query}&start={offset}&gbv=1&gws_rd=ssl') + '?{query}&start={offset}&gws_rd=cr&gbv=1&lr={lang}&ei=x') # other URLs map_hostname_start = 'maps.google.' @@ -160,6 +160,7 @@ def request(query, params): if params['language'] == 'all': language = 'en' country = 'US' + url_lang = '' else: language_array = params['language'].lower().split('_') if len(language_array) == 2: @@ -167,6 +168,7 @@ def request(query, params): else: country = 'US' language = language_array[0] + ',' + language_array[0] + '-' + country + url_lang = 'lang_' + language_array[0] if use_locale_domain: google_hostname = country_to_hostname.get(country.upper(), default_hostname) @@ -175,7 +177,8 @@ def request(query, params): params['url'] = search_url.format(offset=offset, query=urlencode({'q': query}), - hostname=google_hostname) + hostname=google_hostname, + lang=url_lang) params['headers']['Accept-Language'] = language params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'