Browse Source

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

Adam Tauber 9 years ago
parent
commit
6d55642ab4
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      searx/engines/google.py

+ 5
- 2
searx/engines/google.py View File

@@ -90,7 +90,7 @@ url_map = 'https://www.openstreetmap.org/'\
90 90
 search_path = '/search'
91 91
 search_url = ('https://{hostname}' +
92 92
               search_path +
93
-              '?{query}&start={offset}&gbv=1&gws_rd=ssl')
93
+              '?{query}&start={offset}&gws_rd=cr&gbv=1&lr={lang}&ei=x')
94 94
 
95 95
 # other URLs
96 96
 map_hostname_start = 'maps.google.'
@@ -160,6 +160,7 @@ def request(query, params):
160 160
     if params['language'] == 'all':
161 161
         language = 'en'
162 162
         country = 'US'
163
+        url_lang = ''
163 164
     else:
164 165
         language_array = params['language'].lower().split('_')
165 166
         if len(language_array) == 2:
@@ -167,6 +168,7 @@ def request(query, params):
167 168
         else:
168 169
             country = 'US'
169 170
         language = language_array[0] + ',' + language_array[0] + '-' + country
171
+        url_lang = 'lang_' + language_array[0]
170 172
 
171 173
     if use_locale_domain:
172 174
         google_hostname = country_to_hostname.get(country.upper(), default_hostname)
@@ -175,7 +177,8 @@ def request(query, params):
175 177
 
176 178
     params['url'] = search_url.format(offset=offset,
177 179
                                       query=urlencode({'q': query}),
178
-                                      hostname=google_hostname)
180
+                                      hostname=google_hostname,
181
+                                      lang=url_lang)
179 182
 
180 183
     params['headers']['Accept-Language'] = language
181 184
     params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'