@@ -0,0 +1,55 @@
4+ @website https://yandex.ru/
7+ @results HTML (using search portal)
8+ @stable no (HTML can change)
9+ @parse url, title, content
12+from urllib import urlencode
14+from searx.search import logger
16+logger = logger.getChild('yandex engine')
18+# engine dependent config
19+categories = ['general']
21+language_support = True # TODO
24+base_url = 'https://yandex.ru/'
25+search_url = 'search/?{query}&p={page}'
27+results_xpath = '//div[@class="serp-item serp-item_plain_yes clearfix i-bem"]'
28+url_xpath = './/h2/a/@href'
29+title_xpath = './/h2/a//text()'
30+content_xpath = './/div[@class="serp-item__text"]//text()'
33+def request(query, params):
34+ params['url'] = base_url + search_url.format(page=params['pageno']-1,
35+ query=urlencode({'text': query}))
39+# get response from search-request
41+ dom = html.fromstring(resp.text)
44+ for result in dom.xpath(results_xpath):
46+ res = {'url': result.xpath(url_xpath)[0],
47+ 'title': ''.join(result.xpath(title_xpath)),
48+ 'content': ''.join(result.xpath(content_xpath))}
50+ logger.exception('yandex parse crash')