Merge pull request #2430 from return42/fix-2419-ddg

[fix] engine ddg: minor change in the API of ddg
This commit is contained in:
Markus Heiser 2023-05-13 05:55:33 +02:00 committed by GitHub
commit 19ce3d88ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,12 +94,12 @@ def get_vqd(query, headers):
logger.debug("re-use cached vqd value: %s", value)
return value
query_url = 'https://duckduckgo.com/?{query}&iar=images'.format(query=urlencode({'q': query}))
query_url = 'https://duckduckgo.com/?q={query}&atb=v290-5'.format(query=urlencode({'q': query}))
res = network.get(query_url, headers=headers)
content = res.text
if content.find('vqd=\'') == -1:
if content.find('vqd=\"') == -1:
raise SearxEngineAPIException('Request failed')
value = content[content.find('vqd=\'') + 5 :]
value = content[content.find('vqd=\"') + 5 :]
value = value[: value.find('\'')]
logger.debug("new vqd value: %s", value)
cache_vqd(query, value)