.oO SearXNG Developer Documentation Oo.
|
Functions | |
_cache_key (dict data) | |
cache_vqd (dict data, value) | |
get_vqd (data) | |
get_ddg_lang (EngineTraits eng_traits, sxng_locale, default='en_US') | |
Variables | |
logging | logger .Logger |
dict | about |
bool | send_accept_language_header = True |
list | categories = ['general', 'web'] |
bool | paging = True |
bool | time_range_support = True |
bool | safesearch = True |
str | url = "https://html.duckduckgo.com/html" |
dict | time_range_dict = {'day': 'd', 'week': 'w', 'month': 'm', 'year': 'y'} |
dict | form_data = {'v': 'l', 'api': 'd.js', 'o': 'json'} |
list | __CACHE = [] |
dict | ddg_reg_map |
DuckDuckGo Lite ~~~~~~~~~~~~~~~
|
protected |
Definition at line 63 of file duckduckgo.py.
Referenced by searx.engines.duckduckgo.cache_vqd(), and searx.engines.duckduckgo.get_vqd().
searx.engines.duckduckgo.cache_vqd | ( | dict | data, |
value ) |
Caches a ``vqd`` value from a query.
Definition at line 67 of file duckduckgo.py.
References searx.engines.duckduckgo._cache_key().
searx.engines.duckduckgo.get_ddg_lang | ( | EngineTraits | eng_traits, |
sxng_locale, | |||
default = 'en_US' ) |
Get DuckDuckGo's language identifier from SearXNG's locale. DuckDuckGo defines its languages by region codes (see :py:obj:`fetch_traits`). To get region and language of a DDG service use: .. code: python eng_region = traits.get_region(params['searxng_locale'], traits.all_locale) eng_lang = get_ddg_lang(traits, params['searxng_locale']) It might confuse, but the ``l`` value of the cookie is what SearXNG calls the *region*: .. code:: python # !ddi paris :es-AR --> {'ad': 'es_AR', 'ah': 'ar-es', 'l': 'ar-es'} params['cookies']['ad'] = eng_lang params['cookies']['ah'] = eng_region params['cookies']['l'] = eng_region .. hint:: `DDG-lite <https://lite.duckduckgo.com/lite>`__ and the *no Javascript* page https://html.duckduckgo.com/html do not offer a language selection to the user, only a region can be selected by the user (``eng_region`` from the example above). DDG-lite and *no Javascript* store the selected region in a cookie:: params['cookies']['kl'] = eng_region # 'ar-es'
Definition at line 129 of file duckduckgo.py.
searx.engines.duckduckgo.get_vqd | ( | data | ) |
Returns the ``vqd`` that fits to the *query* (``data`` from HTTP POST). DDG's bot detection is sensitive to the ``vqd`` value. For some search terms (such as extremely long search terms that are often sent by bots), no ``vqd`` value can be determined. If SearXNG cannot determine a ``vqd`` value, then no request should go out to DDG: A request with a wrong ``vqd`` value leads to DDG temporarily putting SearXNG's IP on a block list. Requests from IPs in this block list run into timeouts. Not sure, but it seems the block list is a sliding window: to get my IP rid from the bot list I had to cool down my IP for 1h (send no requests from that IP to DDG). TL;DR; the ``vqd`` value is needed to pass DDG's bot protection and is used by all request to DDG: - DuckDuckGo Lite: ``https://lite.duckduckgo.com/lite`` (POST form data) - DuckDuckGo Web: ``https://links.duckduckgo.com/d.js?q=...&vqd=...`` - DuckDuckGo Images: ``https://duckduckgo.com/i.js??q=...&vqd=...`` - DuckDuckGo Videos: ``https://duckduckgo.com/v.js??q=...&vqd=...`` - DuckDuckGo News: ``https://duckduckgo.com/news.js??q=...&vqd=...``
Definition at line 81 of file duckduckgo.py.
References searx.engines.duckduckgo._cache_key().
|
private |
Definition at line 60 of file duckduckgo.py.
dict searx.engines.duckduckgo.about |
Definition at line 36 of file duckduckgo.py.
list searx.engines.duckduckgo.categories = ['general', 'web'] |
Definition at line 51 of file duckduckgo.py.
dict searx.engines.duckduckgo.ddg_reg_map |
Definition at line 168 of file duckduckgo.py.
dict searx.engines.duckduckgo.form_data = {'v': 'l', 'api': 'd.js', 'o': 'json'} |
Definition at line 59 of file duckduckgo.py.
logging searx.engines.duckduckgo.logger .Logger |
Definition at line 32 of file duckduckgo.py.
bool searx.engines.duckduckgo.paging = True |
Definition at line 52 of file duckduckgo.py.
bool searx.engines.duckduckgo.safesearch = True |
Definition at line 54 of file duckduckgo.py.
bool searx.engines.duckduckgo.send_accept_language_header = True |
Definition at line 44 of file duckduckgo.py.
dict searx.engines.duckduckgo.time_range_dict = {'day': 'd', 'week': 'w', 'month': 'm', 'year': 'y'} |
Definition at line 58 of file duckduckgo.py.
bool searx.engines.duckduckgo.time_range_support = True |
Definition at line 53 of file duckduckgo.py.
str searx.engines.duckduckgo.url = "https://html.duckduckgo.com/html" |
Definition at line 56 of file duckduckgo.py.