瀏覽代碼

Revert of #195 when the search language is not english

Sometimes there is two requests to google (depending of the source IP) : one to google.com, the second to google.fr (for instance).

Going to https://www.google.com/ncr and saving the PREF cookie for future use prevent this (there is no redirection).

But, recently (or not ?), by doing this the search returns English results even if the Accept-Language is specified.

There is still a way to prevent this : going to preference, set the search language. I don't know if this can be done by searx.

For now, a quick fix is to disable the use of the PREF cookie when the search language is not English (google engine will slower but returns excepted results).
Alexandre Flament 10 年之前
父節點
當前提交
8a69ade875
共有 1 個檔案被更改,包括 2 行新增1 行删除
  1. 2
    1
      searx/engines/google.py

+ 2
- 1
searx/engines/google.py 查看文件

76
                                       query=urlencode({'q': query}))
76
                                       query=urlencode({'q': query}))
77
 
77
 
78
     params['headers']['Accept-Language'] = language
78
     params['headers']['Accept-Language'] = language
79
-    params['cookies']['PREF'] = get_google_pref_cookie()
79
+    if language.startswith('en'):
80
+        params['cookies']['PREF'] = get_google_pref_cookie()
80
 
81
 
81
     return params
82
     return params
82
 
83