79def request(query, params):
80 """Google-News search request"""
81
82 sxng_locale = params.get('searxng_locale', 'en-US')
83 ceid = locales.get_engine_locale(sxng_locale, traits.custom['ceid'], default='US:en')
84 google_info = get_google_info(params, traits)
85 google_info['subdomain'] = 'news.google.com'
86
87 ceid_region, ceid_lang = ceid.split(':')
88 ceid_lang, ceid_suffix = (
89 ceid_lang.split('-')
90 + [
91 None,
92 ]
93 )[:2]
94
95 google_info['params']['hl'] = ceid_lang
96
97 if ceid_suffix and ceid_suffix not in ['Hans', 'Hant']:
98
99 if ceid_region.lower() == ceid_lang:
100 google_info['params']['hl'] = ceid_lang + '-' + ceid_region
101 else:
102 google_info['params']['hl'] = ceid_lang + '-' + ceid_suffix
103
104 elif ceid_region.lower() != ceid_lang:
105
106 if ceid_region in ['AT', 'BE', 'CH', 'IL', 'SA', 'IN', 'BD', 'PT']:
107 google_info['params']['hl'] = ceid_lang
108 else:
109 google_info['params']['hl'] = ceid_lang + '-' + ceid_region
110
111 google_info['params']['lr'] = 'lang_' + ceid_lang.split('-')[0]
112 google_info['params']['gl'] = ceid_region
113
114 query_url = (
115 'https://'
116 + google_info['subdomain']
117 + "/search?"
118 + urlencode(
119 {
120 'q': query,
121 **google_info['params'],
122 }
123 )
124
125 + ('&ceid=%s' % ceid)
126 )
127
128 params['url'] = query_url
129 params['cookies'] = google_info['cookies']
130 params['headers'].update(google_info['headers'])
131 return params
132
133