@@ -0,0 +1,42 @@
3+from urllib import urlencode
4+from searx.engines.xpath import extract_text, extract_url
7+categories = ['general']
8+search_url = 'http://search.yahoo.com/search?{query}&b={offset}'
9+results_xpath = '//div[@class="res"]'
10+url_xpath = './/h3/a/@href'
11+title_xpath = './/h3/a'
12+content_xpath = './/div[@class="abstr"]'
13+suggestion_xpath = '//div[@id="satat"]//a'
18+def request(query, params):
19+ offset = (params['pageno'] - 1) * 10 + 1
20+ params['url'] = search_url.format(offset=offset,
21+ query=urlencode({'p': query}))
28+ dom = html.fromstring(resp.text)
30+ for result in dom.xpath(results_xpath):
31+ url = extract_url(result.xpath(url_xpath), search_url)
32+ title = extract_text(result.xpath(title_xpath)[0])
33+ content = extract_text(result.xpath(content_xpath)[0])
34+ results.append({'url': url, 'title': title, 'content': content})
36+ if not suggestion_xpath:
39+ for suggestion in dom.xpath(suggestion_xpath):
40+ results.append({'suggestion': extract_text(suggestion)})