diff options
author | Adam Tauber <asciimoo@gmail.com> | 2015-10-31 23:05:07 +0100 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2015-10-31 23:05:07 +0100 |
commit | e98aef6fc4954681e58d774203d522f0ae478004 (patch) | |
tree | f2ecc9f3bb04f5e013fa1e7b4ee3a44993511288 /searx | |
parent | 4b8f9778feab79205bfaa42db55390e058748096 (diff) | |
download | searxng-e98aef6fc4954681e58d774203d522f0ae478004.tar.gz searxng-e98aef6fc4954681e58d774203d522f0ae478004.zip |
[fix] yandex engine language support according to #430
Diffstat (limited to 'searx')
-rw-r--r-- | searx/engines/yandex.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/searx/engines/yandex.py b/searx/engines/yandex.py index a1d2ab792..edc6ad5f2 100644 --- a/searx/engines/yandex.py +++ b/searx/engines/yandex.py @@ -20,8 +20,13 @@ categories = ['general'] paging = True language_support = True # TODO +default_tld = 'com' +language_map = {'ru': 'ru', + 'ua': 'uk', + 'tr': 'com.tr'} + # search-url -base_url = 'https://yandex.ru/' +base_url = 'https://yandex.{tld}/' search_url = 'search/?{query}&p={page}' results_xpath = '//div[@class="serp-item serp-item_plain_yes clearfix i-bem"]' @@ -31,8 +36,10 @@ content_xpath = './/div[@class="serp-item__text"]//text()' def request(query, params): - params['url'] = base_url + search_url.format(page=params['pageno']-1, - query=urlencode({'text': query})) + lang = params['language'].split('_')[0] + host = base_url.format(tld=language_map.get(lang) or default_tld) + params['url'] = host + search_url.format(page=params['pageno']-1, + query=urlencode({'text': query})) return params |