summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2017-06-01 12:01:32 +0200
committerGitHub <noreply@github.com>2017-06-01 12:01:32 +0200
commita932381d7afd84e4ff5b5dab5f306328fb0487c7 (patch)
treef7f78295ae5d791cb7dfbe1ff9fa739d15f501fc
parentc65a409f0d2728ba5a0c3ffa1a0cb05659033a71 (diff)
parent3b950929b10068f08a0ccd877d43e7551bfde71f (diff)
downloadsearxng-a932381d7afd84e4ff5b5dab5f306328fb0487c7.tar.gz
searxng-a932381d7afd84e4ff5b5dab5f306328fb0487c7.zip
Merge pull request #932 from a01200356/duckduckgo
[fix] fix duckduckgo's offset
-rw-r--r--searx/engines/duckduckgo.py7
-rw-r--r--tests/unit/engines/test_duckduckgo.py1
2 files changed, 4 insertions, 4 deletions
diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py
index 1c0587451..8b6411ca2 100644
--- a/searx/engines/duckduckgo.py
+++ b/searx/engines/duckduckgo.py
@@ -79,16 +79,15 @@ def request(query, params):
if params['time_range'] and params['time_range'] not in time_range_dict:
return params
- offset = 30 + (params['pageno'] - 1) * 50
- dc_param = offset + 1
+ offset = (params['pageno'] - 1) * 30
region_code = get_region_code(params['language'])
if region_code:
params['url'] = url.format(
- query=urlencode({'q': query, 'kl': region_code}), offset=offset, dc_param=dc_param)
+ query=urlencode({'q': query, 'kl': region_code}), offset=offset, dc_param=offset)
else:
params['url'] = url.format(
- query=urlencode({'q': query}), offset=offset, dc_param=dc_param)
+ query=urlencode({'q': query}), offset=offset, dc_param=offset)
if params['time_range'] in time_range_dict:
params['url'] += time_range_url.format(range=time_range_dict[params['time_range']])
diff --git a/tests/unit/engines/test_duckduckgo.py b/tests/unit/engines/test_duckduckgo.py
index 8502a2e51..eea478971 100644
--- a/tests/unit/engines/test_duckduckgo.py
+++ b/tests/unit/engines/test_duckduckgo.py
@@ -18,6 +18,7 @@ class TestDuckduckgoEngine(SearxTestCase):
self.assertIn(query, params['url'])
self.assertIn('duckduckgo.com', params['url'])
self.assertIn('ch-de', params['url'])
+ self.assertIn('s=0', params['url'])
# when ddg uses non standard code
dicto['language'] = 'en-GB'