mirror of
https://github.com/searxng/searxng.git
synced 2024-12-23 17:50:29 +00:00
[enh] duckduckgo engine: add language support
This commit is contained in:
parent
1e99cf2a0e
commit
64b75e6d82
1 changed files with 7 additions and 2 deletions
|
@ -18,7 +18,7 @@ from searx.utils import html_to_text
|
|||
# engine dependent config
|
||||
categories = ['general']
|
||||
paging = True
|
||||
locale = 'us-en'
|
||||
language_support = True
|
||||
|
||||
# search-url
|
||||
url = 'https://duckduckgo.com/html?{query}&s={offset}'
|
||||
|
@ -34,8 +34,13 @@ content_xpath = './/div[@class="snippet"]//text()'
|
|||
def request(query, params):
|
||||
offset = (params['pageno'] - 1) * 30
|
||||
|
||||
if params['language'] == 'all':
|
||||
locale = 'en-us'
|
||||
else:
|
||||
locale = params['language'].replace('_','-').lower()
|
||||
|
||||
params['url'] = url.format(
|
||||
query=urlencode({'q': query, 'l': locale}),
|
||||
query=urlencode({'q': query, 'kl': locale}),
|
||||
offset=offset)
|
||||
|
||||
return params
|
||||
|
|
Loading…
Reference in a new issue