on master help sign in
[fix] no more redirect ++ explicitly specify search language to avoid googles ip based heuristics
commit6d55642ab4bb82fe4274acba74464fefefb9f1a2 authorAdam Tauber <asciimoo@gmail.com> dateFri 25 Mar 2016, 18:38 (11 years ago) parentba16f21
1 file changed+5−2
searx/engines/google.py+5−2
searx/engines/google.py+5−2
@@ -90,7 +90,7 @@ url_map = 'https://www.openstreetmap.org/'\
9090search_path = '/search'
9191search_url = ('https://{hostname}' +
9292 search_path +
93− '?{query}&start={offset}&gbv=1&gws_rd=ssl')
93+ '?{query}&start={offset}&gws_rd=cr&gbv=1&lr={lang}&ei=x')
9494
9595# other URLs
9696map_hostname_start = 'maps.google.'
@@ -160,6 +160,7 @@ def request(query, params):
160160 if params['language'] == 'all':
161161 language = 'en'
162162 country = 'US'
163+ url_lang = ''
163164 else:
164165 language_array = params['language'].lower().split('_')
165166 if len(language_array) == 2:
@@ -167,6 +168,7 @@ def request(query, params):
167168 else:
168169 country = 'US'
169170 language = language_array[0] + ',' + language_array[0] + '-' + country
171+ url_lang = 'lang_' + language_array[0]
170172
171173 if use_locale_domain:
172174 google_hostname = country_to_hostname.get(country.upper(), default_hostname)
@@ -175,7 +177,8 @@ def request(query, params):
175177
176178 params['url'] = search_url.format(offset=offset,
177179 query=urlencode({'q': query}),
178− hostname=google_hostname)
180+ hostname=google_hostname,
181+ lang=url_lang)
179182
180183 params['headers']['Accept-Language'] = language
181184 params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'